Skip to content

Instantly share code, notes, and snippets.

@jaydonnell
Created November 29, 2010 18:42
Show Gist options
  • Save jaydonnell/720350 to your computer and use it in GitHub Desktop.
Save jaydonnell/720350 to your computer and use it in GitHub Desktop.
public class ThreadedTest {
private static boolean ready;
private static int number;
private static class ReaderThread extends Thread {
public void run() {
while (!ready)
Thread.yield();
System.out.println(number);
}
}
public static void main(String[] args) {
new ReaderThread().start();
number = 42;
ready = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment