PRINCIPLES OF PROGRAMMING LANGUAGES
PRACT. Write a program in Java to implement concurrent execution of a job using threads.
class Multithreading extends Thread
{
public void run()
{
try
{
System.out.println (“Thread ” +
Thread.currentThread().getId() +
” is running”);
}
catch (Exception e)
{
System.out.println (“Exception is caught”);
}
}
}
public class Multithread
{
public static void main(String[] args)
{
for (int i=0; i<8; i++)
{
Multithreading object = new Multithreading();
object.start();
}
}
}