java threads error!
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.
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: