File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 18523
    
  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: 37991
    
  22
And welcome to the Ranch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java timer task
 
Similar Threads
Timer & TimerTask - Name of Timer Object
Call action class from timertask's run method
How to avoid IllegalStateExceotion in Timer
Making a database connection inside a thread
questions java.util.Timer