Skip to content

Commit def3d75

Browse files
committed
esempio esercizio 3
1 parent 51d79e2 commit def3d75

File tree

1 file changed

+31
-0
lines changed
  • sistemiOperativi/esercitazioni/src/es7

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package es7;
2+
3+
public class Es3 {
4+
5+
public static void main(String[] args) {
6+
BW t1 = new BW(true);
7+
t1.start();
8+
Thread.State s0 = Thread.currentThread().getState();
9+
Thread.State s1 = t1.getState();
10+
System.out.printf("State 0: %s, State 1: %s%n", s0, s1);
11+
t1.bw = s0.equals(s1);
12+
}
13+
14+
static class BW extends Thread {
15+
16+
public boolean bw;
17+
public BW(boolean bw) {
18+
this.bw = bw;
19+
}
20+
21+
@Override
22+
public void run() {
23+
do {
24+
try {
25+
Thread.sleep(10);
26+
} catch (InterruptedException e) { e.printStackTrace();}
27+
} while (bw);
28+
System.out.println("sisop-corsoB");
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)