Added 4th program

This commit is contained in:
Aditya Tiwari
2026-01-23 15:10:24 +05:30
parent 390362a10c
commit 88ea6b90ad
5 changed files with 32 additions and 3 deletions

0
MyThre.java Normal file
View File

BIN
MyThreadd.class Normal file

Binary file not shown.

28
MyThreadd.java Normal file
View File

@@ -0,0 +1,28 @@
public class MyThreadd extends Thread{
String task;
MyThreadd(String task){
this.task = task;
}
public void run(){
for(int i = 1; i<=5; i++){
System.out.println(task+ ":" + i);
try{
Thread.sleep(333);
} catch (InterruptedException ie) {
System.out.println(ie.getMessage());
}
}
} // end of run() method
public static void main(String args[]){
MyThreadd th1 = new MyThreadd("Cut ticket");
MyThreadd th2 = new MyThreadd("Show ticket");
Thread t1 = new Thread(th1);
Thread t2 = new Thread(th2);
t1.start();
t2.start();
}
}

BIN
src/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -1,3 +1,4 @@
1. write a java code by extending thread class
2. write a java code by implementing runnable interface.
3.
1. write a java code by extending thread class (2)
2. write a java code by implementing runnable interface. (2)
3. write a java code for demonstrating thread priority
4. write a java code for two threads performing two tasks at a time