When i try to start Thread (u) it does nothing!
this is what i have inside my class:
private Updater uc;
Thread t1 = new Thread(uc);
-bunch of other code-
t1.start();
Updater.java:
public class Updater implements Runnable{
public void run(){
System.out.println("I work!");
}
}
Output is nothing. Anyone has idea why?
Unless I’m missing something – you never initialize uc:
When you pass null in as the Runnable, then Thread just passes the null value through to an internal init method, which gets called from all of the Thread constructors, including the ones which take no Runnable argument.
In the event that the target Runnable is null, Thread run() simply doesn’t do anything other than exit. Thanks to Jon.