multitreading scheduling related java
Posted
by vichi
on Stack Overflow
See other posts from Stack Overflow
or by vichi
Published on 2010-03-27T20:14:20Z
Indexed on
2010/03/27
20:23 UTC
Read the original article
Hit count: 173
multithreading
class A implements Runnable{
B b=new B();
public void run(){
while(true){
System.out.println("H1"+Thread.currentThread().getName());
}
}
}
public class Test {
public static void main(String[] str){
A a1 =new A();
// A a2 =new A();
//
Thread t1 =new Thread(a1, "Vichi");
Thread t2 =new Thread(a1,"Vishu");
t1.start();
t2.start();
}
}
what will be the ans: 1) only one of them will get the chance to execute 2) both will get chance in arbitrary manner
please suggest possible ans with explations
© Stack Overflow or respective owner