Implementation for thread join and wait and notify design
[IRC.git] / Robust / src / Tests / Atomic3.java
1 public class Atomic3 extends Thread {
2         public Atomic3() {
3         }
4         Tree root;
5         Integer count;
6         public static void main(String[] st) {
7                 int mid = (128<<24)|(195<<16)|(175<<8)|70;
8                 int b;
9                 Atomic3 at3 = null;
10                 Integer y,z;
11                 atomic {
12                         at3 = global new Atomic3();
13                         z = global new Integer(300);
14                         at3.root = global new Tree();
15                         at3.root.insert(z);
16                         b = at3.root.value.intValue();
17                 }
18                 System.printString("b is ");
19                 System.printInt(b);
20                 atomic{
21                         at3.root.item = 2445;
22                         y = global new Integer(400);
23                         at3.root.value = y;
24                         b = at3.root.value.intValue();
25                 }
26                 System.printString("b is ");
27                 System.printInt(b);
28                 System.printString("\n");
29                 System.printString("Starting\n");
30                 at3.start(mid);
31                 System.printString("Finished\n");
32                 while(true) {
33                         ;
34                 }
35         }
36
37         public int run() {
38                 int a;
39                 atomic {
40                         a = root.value.intValue();
41                 }
42                 System.printString("a is ");
43                 System.printInt(a);
44                 System.printString("\n");
45         }
46 }
47
48 public class Tree {
49         public Integer value;
50         public int item;
51         public Tree left;
52         public Tree right;
53
54         public Tree() {
55         }
56
57         public Tree(Integer item) {
58                 value = item;
59                 left = null;
60                 right = null;
61         }
62
63         public Tree(Integer item , Tree l, Tree r) {
64                 value = item;
65                 left =l;
66                 right = r;
67         }
68
69         public Tree insert(Integer a) {
70                 value = a;
71                 left = null;
72                 right = null;
73                 return this;
74         }
75 }