 |
 |
sleep for 30 millis in Java ?
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2001
Status:
Offline
|
|
Is there a way in java to do nothing in a program say for thirty milliseconds without using Threads.sleep() method call. I looked up the documentation but could not find anything.
Thanks,
Erol
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status:
Offline
|
|
you could get the current time, enter a loop that just checks the time against 30 millis from now.
But why not use threads?
|
|
signatures are a waste of bandwidth
especially ones with political tripe in them.
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Apr 2001
Location: Seattle, WA, USA
Status:
Offline
|
|
Originally posted by Kristoff:
you could get the current time, enter a loop that just checks the time against 30 millis from now.
But why not use threads?
There's no reason to not just use the static method in Thread.
Code:
void pause(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
}
}
...
pause(30);
You are using threads in every Java program you write, since even if your program has only a single thread of control, it is by definition in a thread which is separate from the event system, the garbage collector, etc.
-tw
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2001
Status:
Offline
|
|
Thanks a lot guys !
You have helped me a great deal.

|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Feb 2001
Status:
Offline
|
|
Is the equivalent way of sleeping threads in Obj C to
[myThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:.03]];
? This seems reasonable but it also seems a bit heavier than it needs to be. Do you also have to put in an autorelease command, e.g.,
[myThread sleepUntilDate:[[NSDate dateWithTimeIntervalSinceNow:.03] autorelease]];
?
|
|
The 4 o'clock train will be a bus.
It will depart at 20 minutes to 5.
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2001
Location: UK
Status:
Offline
|
|
A quick note of caution:
if you are using the Thread.sleep() method you should be aware that the time the thread will sleep for will be _at least_ the time you specify, but will quite likely be more than that so you cannot depend on sleep for critical timing.
[This message has been edited by ids (edited 04-19-2001).]
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status:
Offline
|
|
That's why Java isn't used in real time systems -yet 
|
|
signatures are a waste of bandwidth
especially ones with political tripe in them.
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Apr 2001
Location: Seattle, WA, USA
Status:
Offline
|
|
Originally posted by Kristoff:
That's why Java isn't used in real time systems -yet
among about 100 other reasons.
http://www.rtj.org/
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|