swag antiswag swag antiswag - 1 year ago 67
Java Question

Why is my thread dead when I run it?

I am trying to do something with my thread when it is dead, but it seems that right when I run it it is already dead...why?

new Thread(){
public void run(){

System.out.println(isAlive());//prints out false

Answer Source


.run() //is not a valid way to start a Thread.

change to

.start();//Valid way to start a thread

Heres the Thread API link:


I think you got confused between the Runnable run() and the Thread start().

Heres the Runnable Interface API:


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download