java threads error!

Asked by ehdm

hi. i just installed sun java 6 and tried some tutorials on thread.

found this problem,
two different programs each with two threads i.e the main thread and another one, same name, called class MyThread extends Thread.
compiled ok, run ok, if executed one by one.
problem is when i run program b after recently compiled program a, the output of thread named MyThread is coming from program a instead of program b. main() program a start the wrong thread.

Somehow it caches the thread on same name??? Tried change to different name, problem disappeared.
Can those threads mixed up? I confirm that with giving different super ("name"), and print getName(), and to my dissapointment it DOES mix up!! even though program a is already terminated, its thread still cached?

Question, is it that BAD??? This is something that hard to accept. On SUN's Java ? Oh, I tried also at the other O/S (M$ Win*ows), same sad result.
Maybe I made some error somewhere.. Please enlighten me.

I don't understand...

public static void main(String[] args) {
Mythread mt = new MyThread(); // ?????
mt.start;
..
If so then the 'new' keyword does not mean as it sound, if it already ever been defined in memory (TSR, zombie?) then use it? Sound like a serious error to me, but is it a fact?

those examples are from www.javaworld.com/javaworld/jw-05-2002/jw-0503-java101.html
Listing 1 versus Listing 3.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
ehdm
Solved:
Last query:
Last reply:
Revision history for this message
ehdm (emangindaan) said :
#1

sorry, i mean,
MyThread mt = new MyThread(); //
mt.start;

jvm start the wrong public void run() of the MyThread on other program.

Revision history for this message
Vadim Peretokin (vperetokin) said :
#2

There's a 'Programming talk' thread on the Ubuntu forums (http://ubuntuforums.org/forumdisplay.php?f=39), I believe you'll get more help there.

This place is just for Ubuntu-specific questions, not programming help :\

Revision history for this message
ehdm (emangindaan) said :
#3

Oops,
nevermind. bye.