first commit

This commit is contained in:
2026-01-29 14:05:10 +05:30
commit 00b45c11a4
14 changed files with 137 additions and 0 deletions

25
MyThread.java Normal file
View File

@@ -0,0 +1,25 @@
// write a java code for two thread performing two task at a time
public class MyThread extends Thread{
String task;
MyThread(String task){
this.task = task;
}
public void run(){
synchronized(this) {
for(int i=1;i<=5;i++){
System.out.println(task + ":" + i);
try {
Thread.sleep(1000);
}catch(InterruptedException ie){
System.out.println(ie.getMessage());
}
}
}
}
public static void main(String args[]){
MyThread th1 = new MyThread("Cut the ticket");
MyThread th2 = new MyThread("Show your seat number");
th1.start();
th2.start();
}
}