Norm, jps, thank you very much! Now I see it. Actually, it becomes very, very obvious in a debugger. So in the first iteration we had a direct call to the target run() method. At the end of this...
Type: Posts; User: angstrem
Norm, jps, thank you very much! Now I see it. Actually, it becomes very, very obvious in a debugger. So in the first iteration we had a direct call to the target run() method. At the end of this...
But if I pass a Runnable to a Thread constructor, the Runnable's run() method will be called on thread's start. Thread implements Runnable. Hence, when I say t = new Thread(t) the new thread must run...
OK, here's the full code:
public class Program {
public static void main(String[] args) throws InterruptedException {
Thread t = new Thread(){
public void run(){...
In fact, this already is a small, complete program. Just wrap the code in the main method and that's it.
I have the following code:
Thread t = new Thread(){
public void run(){
System.out.println("I'm called!");
}
...