Bugs item #1561340, was opened at 2006-09-19 14:21
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=438935&aid=1561340&group_id=44253
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Other
Group: 5: Makes DrJ unstable
Status: Open
Resolution: None
Priority: 5
Submitted By: Abhishek (abhishekasthana)
Assigned to: Nobody/Anonymous (nobody)
Summary: Some problem with Threads
Initial Comment:
I don't know if this is a bug or not, but one this is
for sure DrJava is giving wrong output. I checked the
o/p by running the program on command prompt and the
o/p is what it should be.
I am running this program:
class MyThread2 extends Thread{
static int i= 0;
String name;
MyThread2(String n){
name=n;
}
public synchronized void syn(String n){
for(int k=0;k<5;k++){
i++;
System.out.println(n+" "+i);
}
}
public void run(){
System.out.println("before: "+name);
syn(name);
System.out.println("after: "+name);
}
public static void main(String args[]){
MyThread2 m1=new MyThread2("m1");
MyThread2 m2=new MyThread2("m2");
m1.start();
m2.start();
}
}
and o/p from DrJava is:
before: m1
before: m2
m1 1
m2 2
m1 3
m2 4
m1 5
m2 6
m1 7
m2 8
m1 9
m2 10
after: m1
after: m2
Which is undoubtedly wrong since syn is a
synchronized method. The o/p from command prompt is:
before: m1
m1 1
m1 2
m1 3
m1 4
m1 5
after: m1
before: m2
m2 6
m2 7
m2 8
m2 9
m2 10
after: m2
Which is what it should be, atmax the order of m1 and
m2 can reverse.
Please see if this is a bug. If it is something else,
or my error please inform me.
Thanks.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=438935&aid=1561340&group_id=44253
|