1public class LambdaThreadTest {
2 public static void main(String args[]) {
3 // Child thread
4 new Thread(() -> { // Lambda Expression
5 for(int i=1; i <= 5; i++) {
6 System.out.println("Child Thread: "+ i);
7 try {
8 Thread.sleep(500);
9 } catch(Exception e) {
10 e.printStackTrace();
11 }
12 }
13 }).start();
14 // Main Thead
15 for(int j=1; j < 5; j++) {
16 System.out.println("Main Thread: "+ j);
17 try {
18 Thread.sleep(500);
19 } catch(Exception e) {
20 e.printStackTrace();
21 }
22 }
23 }
24}