0% found this document useful (0 votes)
18 views2 pages

Yogesh - Java - No21 (1) Done

The document describes implementing multithreading in Java to allow simultaneous execution of Process1 and Process2 by extending the Thread class and overriding the run method, and calling start on each process.

Uploaded by

suya24telang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Yogesh - Java - No21 (1) Done

The document describes implementing multithreading in Java to allow simultaneous execution of Process1 and Process2 by extending the Thread class and overriding the run method, and calling start on each process.

Uploaded by

suya24telang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical no21

Name:-suyash telang

Roll no:32

Aim: implement multithreading to perform simultaneous process

class Process1 extends Thread {

public void run() {

System.out.println("Process 1 is executing...");

try {

Thread.sleep(2000);

} catch (InterruptedException e) { e.printStackTrace();

System.out.println("Process 1 is done.");

class Process2 extends Thread {

public void run() {

System.out.println("Process 2 is executing...");
try {

Thread.sleep(3000);

} catch (InterruptedException e) { e.printStackTrace();

System.out.println("Process 2 is done.");

public class MultithreadingExample{ public


static void main(String[] args) { Process1
process1 = new Process1();

Process2 process2 = new Process2();

process1.start();
process2.start();

Output:

You might also like