Hi there, I have two questions on Java Timer. Say, I use a Timer to schedule several recurring TimerTasks (e.g., they execute every a few hours, etc.). Since by default Timer runs as a user thread, would that keep my application from terminating? The JavaDoc on Timer says that only after all the scheduled tasks complete (what defines "Complete" for recurring TimerTasks, would they ever complete??), the Timer's thread would then terminate. So, if I call System.exit(0) from my code, would my application exit immediately or does it has to wait till all timer tasks complete? The second question is that in addition to these TimerTasks, I also want to schedule another TimerTask, whose execution requires me to exit the application and restart it, and this task can only run if no other TimerTask is running. My question is, how would I know that no TimerTask is running at any given moment? Thanks. Yan
I think I found the answer to the 2nd question, only. Since I create all the TimerTask objects using the same Timer, they are executed one at a time, with only one runs at any given time. So, there is no need for checking no other TimerTask is running, because there will be none.