8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6961dab commit 4c45fadCopy full SHA for 4c45fad
src/main/java/java_volatile/TaskRunner.java
@@ -0,0 +1,26 @@
1
+package java_volatile;
2
+
3
+public class TaskRunner {
4
+ private static int number;
+ private static boolean ready;
6
7
+ private static class Reader extends Thread {
8
+ @Override
9
+ public void run() {
10
+ System.out.println("ready is: " + ready);
11
+ while (!ready) {
12
+ System.out.println("It's yielding now..");
13
+ Thread.yield();
14
+ }
15
+ System.out.println("number is: " + number);
16
17
18
19
+ public static void main(String[] args) {
20
+ System.out.println("Program started.");
21
+ new Reader().start();
22
+ number = 42;
23
+ ready = true;
24
+ System.out.println("Program finished.");
25
26
+}
0 commit comments