J
jammytech
I'm a newbie to java and I have the following Q -
class mythread implements Runnable {
..
..
..
}
scenario 1
mythread my = new mythread();
Thread t1 = new Thread(my);
Thread t2 = new Thread(my);
t1.start();
t2.start();
scenario 2
mythread my1 = new mythread();
mythread my2 = new mythread();
Thread t1 = new Thread(my1);
Thread t2 = new Thread(my2);
t1.start();
t2.start();
Whats the difference b/w scenario 1 and 2 ?. I'm kind of confused here.
Debugger shows me that two threads are created in both scenarios.
-j
class mythread implements Runnable {
..
..
..
}
scenario 1
mythread my = new mythread();
Thread t1 = new Thread(my);
Thread t2 = new Thread(my);
t1.start();
t2.start();
scenario 2
mythread my1 = new mythread();
mythread my2 = new mythread();
Thread t1 = new Thread(my1);
Thread t2 = new Thread(my2);
t1.start();
t2.start();
Whats the difference b/w scenario 1 and 2 ?. I'm kind of confused here.
Debugger shows me that two threads are created in both scenarios.
-j