f9a74a6d825a3a376658ea0da65f1a6eb383a86d
[IRC.git] / Robust / src / Tests / Atomic5.java
1 public class Atomic5 extends Thread {
2         public People[] team;
3         public Atomic5() {
4         }
5         public static void main(String[] st) {
6                 int mid = (128<<24)|(195<<16)|(175<<8)|70;
7                 int b = 0,c = 0;
8                 
9                 Integer age;
10                 Atomic5 tmp;
11                 Atomic5[] at5;
12                 atomic {
13                         at5 =  global new Atomic5[4];
14                 }
15                 atomic {
16                         for(int i = 0; i < 4; i++) {
17                                 at5[i] = global new Atomic5();
18                                 at5[i].team = global new People[2];
19                                 at5[i].team[0] = global new People();
20                                 at5[i].team[1] = global new People();
21                                 age = global new Integer(35);
22                                 at5[i].team[0].age = age;
23                         }
24                         b = at5[1].team[0].getAge();
25                 }
26                 System.printInt(b);
27                 System.printString("\n");
28                 atomic {
29                         age = global new Integer(70);
30                         at5[1].team[1].age = age;
31                         c = at5[1].team[1].getAge();
32                 }
33                 System.printInt(c);
34                 System.printString("\n");
35                 System.printString("Starting\n");
36                 for(int i = 0 ; i< 4; i++) {
37                         atomic {
38                                 tmp = at5[i];
39                         }
40                         tmp.start(mid);
41                 }
42                 /*
43                 for(int i = 0; i< 4; i++) {
44                         atomic {
45                                 tmp = at5[i];
46                         }
47                         tmp.join();
48                 }
49                 */
50                 System.printString("Finished\n");
51                 while(true) {
52                         ;
53                 }
54         }
55
56         public void run() {
57                 /*
58                 int ag;
59                 boolean old = false;
60                 atomic {
61                         ag = team[1].getAge();
62                         if(ag > 65)
63                                 old = true;
64                 }
65                 if(old){
66                         System.printString(" gets Pension"); 
67                         System.printString("\n");
68                 }
69                 */
70                 System.printString("Atomic5() Inside the run program"); 
71                 System.printString("\n");
72                 /*
73                 for(int i=0; i<4 ; i++) {
74                         at5[i].join();
75                 }
76                 */
77         }
78 }
79
80 public class People {
81         Integer age;
82
83         public People() {
84         }
85
86         public People(Integer age) {
87                 this.age = age;
88         }
89
90         public void setAge(Integer a) {
91                 age = a;
92         }
93
94         public int getAge() {
95                 return age.intValue();
96         }
97
98         public boolean isSenior() {
99                 if(this.getAge() > 65)
100                         return true;
101                 return false;
102         }
103 }