You are on page 1of 3

Program-1 // Write a class having three threads. Set three different priority to them.

Run the program to see the effect class A extends Thread pu!lic void run"#

System.out.println"$threadA started$#% for"int i&1%i'&(%i))#

System.out.println"$from thread A*i&$)i#% + System.out.println"$exit from A$#% + + class , extends Thread

pu!lic void run"#

System.out.println"$thread, started$#% for"int -&1%-'&(%-))#

System.out.println"$from thread ,*-&$)-#% + System.out.println"$exit from ,$#%

+ + class . extends Thread

pu!lic void run"#

System.out.println"$thread. started$#% for"int /&1%/'&(%/))#

System.out.println"$from thread .*/&$)/#% + System.out.println"$exit from .$#% + + class ThreadPriority

pu!lic static void main"String args01#

A threadA&ne2 A"#% , thread,&ne2 ,"#% . thread.&ne2 ."#% thread..setPriority"Thread.3A45PR67R6T8#% thread,.setPriority"threadA.getPriority"#)1#% threadA.setPriority"Thread.3695PR67R6T8#%

System.out.println"$start thread A$#% threadA.start"#% System.out.println"$start thread ,$#% thread,.start"#% System.out.println"$start thread .$#% thread..start"#% System.out.println"$end of main thread$#% + +

You might also like