-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyClass2.java
More file actions
23 lines (18 loc) · 753 Bytes
/
Copy pathMyClass2.java
File metadata and controls
23 lines (18 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package concurrency.thread;
public class MyClass2 implements Runnable {
@Override
public void run() {
System.out.println("Thread :"+ Thread.currentThread().getName() + " is being executed.");
}
public static void main(String[] args) {
new Thread(new MyClass2()).start();
new Thread(new MyClass2()).start();
//because Runnable is Functional interface, so you can use lambda to write implementation.
new Thread(()->{
System.out.println("Thread :"+ Thread.currentThread().getName() + " is being executed.");
}).start();
new Thread(()->{
System.out.println("Thread :"+ Thread.currentThread().getName() + " is being executed.");
}).start();
}
}