???????????????????????????????java??Timer???????ж??????????????й?Timer???Щ???????
???????Timer???????????????????TimerTask?????????????run??????????????????TimerTask????????????????????????:
????Timer timer = new Timer();
????timer.schedule(new TimerTask() {
????public void run() {
????System.out.println("11232");
????}
????}?? 200000 ?? 1000);
?????????????????TimerTask(???????????????TimerTask?????TimerTask????????Timer????????? Timer?б??????????????Timer??????????????????????)??????дrun??????20s?????У?????????Σ???????????? timer?????????????timerTask?????timerTask??????????壬????timer?????????????????????????ж????run ?????????????????????????????????Runnable???????????????????????????????????????????
?????????timer?????????????????Timer??????Щ??????????
????1?????????????????task??????delay(ms)??????е??????????????Ρ?
????public void schedule(TimerTask task?? long delay)
????2?????????????time???????Ρ?
????public void schedule(TimerTask task?? Date time)
????3?????????????????task????delay??ms????????????ε??????????period??ms????????????
????public void schedule(TimerTask task?? long delay?? long period)
????4???????????????????????????????????????????ε???????
????public void schedule(TimerTask task?? Date firstTime?? long period)
????5?????????task????delay(ms)????????????????period(ms)??ε????ò????????schedule?????????????????????????????????schedule????????????е?????????????????????????????????? + ????????scheduleAtFixedRate?????????????????е????????????????????е????+ ??????????????е??????????????????????????磺schedule??????5s??????????????5??10??15??20??Щ???????????????????????ЩCPU???????δ???????????????8s???????ε???????schedule???????????????????????????13s???????10s???????п????′????20s????????????λ??Σ???scheduleAtFixedRate????????????????????????????????????????????8s?????????????????????10s??????????????????2s??????????????????У??????????????????????????????????
????public void scheduleAtFixedRate(TimerTask task?? long delay?? long period)
????6?????????????????????ε??????????????Date??????????????????????????????????л?????????Щ?????
????public void scheduleAtFixedRate(TimerTask task?? Date firstTime??long period)
?????????
?????????Timer????????м????
??????????1????ι????????????Tiemer??????????????????
????public Timer() {
????this("Timer-" + serialNumber());
????}
?????????????????????????????????timer??????????????????cancel??????timer???????
??????????2??????????????????????????????????????????????????
????public Timer(boolean isDaemon) {
????this("Timer-" + serialNumber()?? isDaemon);
????}
??????????????????????????????timer?????
????public Timer(String name?? boolean isDaemon) {
????thread.setName(name);
????thread.setDaemon(isDaemon);
????thread.start();
????}
?????????????thread?????thread????????????????????????Timer???У???????????thread????????
????private TimerThread thread = new TimerThread(queue);