class A implements Runnable { public void run() { System.out.println(Thread.currentThread()); //Thread.yield(); System.out.println(Thread.currentThread()); } } class Test { public static void main(String args[]) { A a1=new A(); A a2=new A(); A a3=new A(); Thread t1=new Thread(a1,"SINGO"); Thread t2=new Thread(a2,"BINGO"); t1.setPriority(2);t2.setPriority(7); t1.start();t2.start(); } }
why there is no difference in output after commenting the Thread.yield( )
with Thread.yield( ) & Without Thread.yield( ) output is
Thread[SINGO,2,main]
Thread[BINGO,7,main]
Thread[SINGO,2,main]
Thread[BINGO,7,main]