fixed bug
[IRC.git] / Robust / src / Tests / Atomic4.java
1 public class Atomic4 extends Thread {
2         public Atomic4() {
3                 People[] team = new People[2];
4         }
5         People[] team;
6         public static void main(String[] st) {
7                 int mid = (128<<24)|(195<<16)|(175<<8)|70;
8                 int b,c;
9                 
10                 Integer age;
11                 String name;
12                 Atomic4 at4 = null;
13                 atomic {
14                         at4 = global new Atomic4();
15                         age = global new Integer(35);
16                         name = global new String("Harry Potter");
17                         at4.team[0] = global new People(name, age);
18                         b = at4.team[0].getAge();
19                 }
20                 atomic {
21                         age = global new Integer(70);
22                         name = global new String("John Smith");
23                         at4.team[1] = global new People(name,age);
24                         c = at4.team[1].getAge();
25                 }
26                 System.printInt(b);
27                 System.printString("\n");
28                 System.printString("Starting\n");
29                 at4.start(mid);
30                 System.printString("Finished\n");
31                 while(true) {
32                         ;
33                 }
34         }
35
36         public int run() {
37                 String name = "";
38                 int a;
39                 boolean old = false;
40                 atomic {
41                         a = team[1].getAge();
42                         name = team[1].getName();
43                         if(a > 65)
44                                 old = true;
45                 }
46                 if(old){
47                         System.printString(" gets Pension"); 
48                         System.printString("\n");
49                 }
50         }
51 }
52
53 public class People {
54         String name;
55         Integer age;
56
57         public People(String name, Integer age) {
58                 this.name = name;
59                 this.age = age;
60         }
61
62         public String getName() {
63                 return name;
64         }
65
66         public int getAge() {
67                 return age.intValue();
68         }
69
70         public boolean isSenior() {
71                 if(this.getAge() > 65)
72                         return true;
73                 return false;;
74         }
75 }