diff --git a/MyThre.java b/MyThre.java new file mode 100644 index 0000000..e69de29 diff --git a/MyThreadd.class b/MyThreadd.class new file mode 100644 index 0000000..5cb4a62 Binary files /dev/null and b/MyThreadd.class differ diff --git a/MyThreadd.java b/MyThreadd.java new file mode 100644 index 0000000..7ce7e43 --- /dev/null +++ b/MyThreadd.java @@ -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(); + } +} + + + \ No newline at end of file diff --git a/src/4.png b/src/4.png new file mode 100644 index 0000000..9fdc5c1 Binary files /dev/null and b/src/4.png differ diff --git a/src/Title.txt b/src/Title.txt index bc1eab6..1810120 100644 --- a/src/Title.txt +++ b/src/Title.txt @@ -1,3 +1,4 @@ -1. write a java code by extending thread class -2. write a java code by implementing runnable interface. -3. \ No newline at end of file +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 \ No newline at end of file