Created
November 29, 2010 18:42
-
-
Save jaydonnell/720350 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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