program in Java to implement concurrent execution of a job using threads.

March 28, 2019 · Team EasyExamNotes · 1 min read (est.) · 0 comments

Share on WhatsApp
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(); 
} 
} 
} 

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion