X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FTests%2FAtomic4.java;h=3034dc33784c5ad57161af504d924b84eb5208f8;hb=8ba6ffae3e7090c3f0a1693727d1cfc4bd493c03;hp=c4c4c492294e333e0aa3aadb368f9bfc875efec4;hpb=431dc545da06cfaecfc9ff57935aa16a8a29d602;p=IRC.git diff --git a/Robust/src/Tests/Atomic4.java b/Robust/src/Tests/Atomic4.java index c4c4c492..3034dc33 100644 --- a/Robust/src/Tests/Atomic4.java +++ b/Robust/src/Tests/Atomic4.java @@ -1,31 +1,32 @@ public class Atomic4 extends Thread { - People[] team; + public People[] team; public Atomic4() { - People[] team = new People[2]; } public static void main(String[] st) { int mid = (128<<24)|(195<<16)|(175<<8)|70; - int b,c; + int b = 0,c = 0; Integer age; - String name; Atomic4 at4 = null; + atomic { at4 = global new Atomic4(); + at4.team = global new People[2]; + at4.team[0] = global new People(); + at4.team[1] = global new People(); + } + atomic { age = global new Integer(35); - name = global new String("Harry Potter"); - at4.team[0].name = name; at4.team[0].age = age; b = at4.team[0].getAge(); } atomic { age = global new Integer(70); - name = global new String("John Smith"); - at4.team[1].name = name; at4.team[1].age = age; c = at4.team[1].getAge(); } System.printInt(b); + System.printString("\n"); System.printInt(c); System.printString("\n"); System.printString("Starting\n"); @@ -37,17 +38,19 @@ public class Atomic4 extends Thread { } public int run() { - String newname = ""; int ag; boolean old = false; atomic { ag = team[1].getAge(); - newname = team[1].getName(); + //ag = team[0].getAge(); if(ag > 65) old = true; } if(old){ - System.printString(" gets Pension"); + System.printString("Gets Pension"); + System.printString("\n"); + } else { + System.printString("Gets No Pension"); System.printString("\n"); } } @@ -57,6 +60,9 @@ public class People { String name; Integer age; + public People() { + } + public People(String name, Integer age) { this.name = name; this.age = age; @@ -75,14 +81,12 @@ public class People { } public int getAge() { - int test = age.intValue(); - //return age.intValue(); - return test; + return age.intValue(); } public boolean isSenior() { if(this.getAge() > 65) return true; - return false;; + return false; } }