Advertisement
JeffGrigg

Two Thread Example

Nov 4th, 2018
547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.48 KB | None | 0 0
  1. public class MyClass extends Thread {
  2.     public static void main(String[] args) {
  3.         MyClass thread1 = new MyClass() {
  4.             @Override
  5.             public void run() {
  6.                 System.out.println("Task1");
  7.             }
  8.         };
  9.         MyClass thread2 = new MyClass() {
  10.             @Override
  11.             public void run() {
  12.                 System.out.println("Task2");
  13.             }
  14.         };
  15.         thread1.start();
  16.         thread2.start();
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement