Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
41 lines (34 loc) · 1.31 KB

File metadata and controls

41 lines (34 loc) · 1.31 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package com.tutorial.threads;
public class Threads_01_02 {
public static void main(String[] args)
{
//Create a thread using a class that implements runnable
(new HelloRunnable()).start();
//Create a thread using a class that extends Thread
(new HelloThread()).start();
//Create a runnable object
Runnable r1 = new Runnable()
{
@Override
public void run()
{
//perform some work inside the thread
System.out.println("Hello from "+
Thread.currentThread().getName()
+ " NOT USING LAMBDA");
}
};
//Create a runnable object using lambda notation
Runnable r2 = () -> System.out.println("Hello from "
+ Thread.currentThread().getName()+" USING LAMBDA "
+ "notation");
/*Create and start a thread using the first runnable object
*This thread is also given a name in the arguments */
Thread t1 = new Thread(r1, "Thread t1");
t1.start();
/*Create and start a second thread using the runnable object with
*lambda notation and not given a name */
Thread t2 = new Thread(r2);
t2.start();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.