Thread: Java Threads
View Single Post
  #3   Spotlight this post!  
Unread 13-03-2011, 19:17
colinwarren colinwarren is offline
King of the Code Monkeys
AKA: Colin Warren
FRC #2456 (Recycle It!)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Marin
Posts: 8
colinwarren is an unknown quantity at this point
Re: Java Threads

Quote:
Originally Posted by Ether View Post
Sleep() makes the thread not runnable so it releases the processor so it doesn't waste resources polling the clock. The sleeping thread becomes runnable again when the sleep period has expired.


How is Timer.delay() implemented?

Code:
public static void delay(final double seconds) {
        try {
            Thread.sleep((long) (seconds * 1e3));
        } catch (final InterruptedException e) {
        }
    }
From WPILibJ's source. I would expect that the C++ threads are implemented on top of usleep(3).
__________________
Reply With Quote