Meaningless Drivel is fun!*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java timer task" Watch "Java timer task" New topic
Author

Java timer task

srinivasu kondreddy
Greenhorn

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?

Regards,
Srinu.k.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18752
    
  40

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.

Henry


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

Joined: Oct 13, 2005
Posts: 38436
    
  23
And welcome to the Ranch
 
jQuery in Action, 2nd edition
 
subject: Java timer task