Results 1 to 6 of 6
- 12-14-2010, 12:25 PM #1
Member
- Join Date
- Dec 2010
- Location
- Israel
- Posts
- 4
- Rep Power
- 0
Running a thread for a fixed period of time
Hello,
I am trying to find a way to run a thread for a fixed period of time and then to stop it.
For example, if the program will receive an input telling it to run some task for 5 seconds, it will create a new thread (for example containing an endless loop which prints something), and this thread will run for 5 seconds, printing, and then it will stop.
How can I do this?
Thanks :)
- 12-14-2010, 01:26 PM #2
The most obvious way would be to check the elapsed time at the beginning of each loop iteration.
- 12-14-2010, 01:40 PM #3
Member
- Join Date
- Dec 2010
- Location
- Israel
- Posts
- 4
- Rep Power
- 0
Thank you for your reply.
What is the method for checking the the elapsed time?
- 12-14-2010, 01:44 PM #4
What did google tell you?
Hint: System (Java Platform SE 6)
- 12-14-2010, 01:47 PM #5
Member
- Join Date
- Dec 2010
- Location
- Israel
- Posts
- 4
- Rep Power
- 0
Thanks again :)
- 12-16-2010, 07:26 PM #6
Member
- Join Date
- Dec 2010
- Location
- Israel
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
take the total time for particular period
By baktha.thalapathy in forum New To JavaReplies: 3Last Post: 06-08-2010, 09:42 AM -
calculate time diff for particular time period
By baktha.thalapathy in forum New To JavaReplies: 2Last Post: 05-24-2010, 04:10 PM -
Running thread a second time
By Fleur in forum New To JavaReplies: 18Last Post: 11-17-2009, 12:57 PM -
need info on running thread during a particular time interval alone
By karthikeyan_raju in forum Threads and SynchronizationReplies: 2Last Post: 10-06-2009, 02:40 AM -
signing applets for a period of time
By sandeepk84@gmail.com in forum Java AppletsReplies: 0Last Post: 12-04-2007, 01:34 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks