File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Java Timer in Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Java Timer in Thread" Watch "Java Timer in Thread" New topic
Author

Java Timer in Thread

RickVorster
Greenhorn

Joined: May 20, 2002
Posts: 1
I have a multithreaded listener program whose purpose is to receive ASN.1 messages. If a new socket connection is received I spwan a new thread. Now part of the incoming message is a timeout value. This is where the problem comes in. With this timeout value I need to start a specified "Job". If this "Job" does not complete in the set time, an exception must be thrown so that I can take alternative action.
I fiddled with the Timer class but to no avail. Any help would be appreciated.
TIA
Robert Ziel
Greenhorn

Joined: Apr 22, 2002
Posts: 28
Hi,
subscribe to the techtips.
this week's tip is about this topic and you will find your answer there.
Techtip Timer
Robert
[ May 22, 2002: Message edited by: Robert Ziel ]
netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
I too have been fiddling with the same problem ,if u could find any reply that will be helpful for me.And do u know how to make a thread sleep for some seconds for eg.30.I tried using
Thread.sleep(1800);
but it waits only for 2 seconds what is the actual problem?Waiting for some reply.
Happy middling with java.
Netharam.
Robert Ziel
Greenhorn

Joined: Apr 22, 2002
Posts: 28
Hi,
sleep(1800) is 1.8 second
sleep(30000) 30 seconds
or could be a bit more see the api
Robert
 
IntelliJ Java IDE
 
subject: Java Timer in Thread
 
Threads others viewed
java.util.Timer inside Runnable?
Flow of Code Control
Interrupting Events
Need to restart timer with different time
Thread waiting for another thread
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture