-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunnable_Lambda.java
More file actions
44 lines (36 loc) · 1.08 KB
/
Copy pathRunnable_Lambda.java
File metadata and controls
44 lines (36 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//Implementation of Runnable Imterface using Lambda function
public class Runnable_Lambda
{
public static void main(String[] args) {
{
Runnable obj1=()-> //Lambda Function 01
{
for(int i=0; i<20; i++)
{
System.out.println("Hi");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
System.out.println(e);
}
}
};
Runnable obj2= ()-> //Lambda function 02
{
for(int i=0; i<20; i++)
{
System.out.println("Hello");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
System.out.println(e);
}
}
};
Thread t1=new Thread(obj1);
Thread t2=new Thread(obj2);
t1.start();
t2.start();
}
}
}