Two Threads without Inheritance
public class MyClass {
public static void main(String[] args) throws InterruptedException {
Thread thread1 = new Thread() {
@Override
public void run() {
System.out.println("Task1");
}
};
Thread thread2 = new Thread() {
@Override
public void run() {
System.out.println("Task2");
}
};
thread1.start();
thread2.start();
thread1.join();
thread2.join();
}
}
Comments
0 B
|👍
/👎