public class RacyThread1 extends Thread {
private Data d;
public RacyThread1(Data d)
{
this.d = d;
}
public void run()
{
while(true)
{
d.setData(10);
if(d.getData() != 10)
System.out.println("\nThread 1 observed value for x: " + d.getData());
}
}
}
Thread 2:
public class RacyThread2 extends Thread {
private Data d;
public RacyThread2(Data d)
{
this.d = d;
}
public void run()
{
while(true)
{
d.setData(20);
}
}
}
Main:
public class Driver {
/**
* @param args
*/
private static Data d;
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
d = new Data(0);
RacyThread1 t1 = new RacyThread1(d);
RacyThread2 t2 = new RacyThread2(d);
t1.start();
t2.start();
t1.join();
t2.join();
}
}
java -cp chord-src-2.1/chord.jar -Dchord.work.dir=project -Dchord.run.analyses=datarace-java -Dchord.kobj.k=3 -Dchord.inst.ctxt.kind=co chord.project.Boot
--
You received this message because you are subscribed to the Google Groups "chord-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chord-discus...@googlegroups.com.
To post to this group, send email to chord-...@googlegroups.com.
Visit this group at http://groups.google.com/group/chord-discuss.
For more options, visit https://groups.google.com/d/optout.