File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Java timer task Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java timer task" Watch "Java timer task" New topic

Java timer task

srinivasu kondreddy

Joined: Feb 28, 2010
Posts: 1
Hi All,

I am using java timer task in my project. I am using scheduleAtFixedRate() method. If i am scheduling more tasks , some times newly schedule tasks are not running(control is not comming to run method) untill finishing the earlier tasks. Any body can help me to reslove this problem. please educate me how many tasks i can run simultaniusly . Is ther any chance to find newly schedule task status?

Henry Wong

Joined: Sep 28, 2004
Posts: 20535

The java.util.Timer class only has one thread to run the tasks. Hence, it is not possible to run the next task, until the previous one finishes. If you want to schedule into more than one thread, take a look at java.util.concurrent.ScheduledThreadPoolExecutor class.

However, even in this case, i don't think it will schedule the same task to run again, if the previous iteration is not complete.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46405
And welcome to the Ranch
I agree. Here's the link:
subject: Java timer task
It's not a secret anymore!