7 C. Write a java program to implement multithreading.

 Program :


class MultiThreading  extends  Thread

{

public void run()

{

try{

for(int i=1;i<11;i++)

{

System.out.println(i);

Thread.sleep(500);

}

}

catch(Exception e)

{}

}


public static void main(String args[])

{

MultiThreading t1=new MultiThreading();

MultiThreading t2=new MultiThreading();


try{

t1.setName("My first thread");

t1.start();

t1.join();


t2.start();

}

catch(Exception e)

{}


}


}


Comments

Popular posts from this blog

Create an android app that demonstrates Activity Lifecycle and Instance State.

Program using Light Sensitive Sensors on Tinkercad