Click here to watch in Youtube :
https://www.youtube.com/watch?v=4qHFrzYJ1XU&list=UUhwKlOVR041tngjerWxVccw
LambdaDemo.java
https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_thread_create_App.zip?attredirects=0&d=1
https://www.youtube.com/watch?v=4qHFrzYJ1XU&list=UUhwKlOVR041tngjerWxVccw
LambdaDemo.java
/**
* With JDK 8
*
* Java Lambda Expression Example: Creating Thread
*
*/
public class LambdaDemo
{
public static void main(String[] args)
{
/*
* Thread Example with lambda.
*
* we are implementing run method by using lambda expression.
*/
Runnable runnable = () -> {
System.out.println("Thread is running...");
};
Thread thread = new Thread(runnable);
thread.start();
}
}
OutputThread is running...
NonLambdaDemo.java/**
* Before JDK 8
*
*/
public class NonLambdaDemo
{
public static void main(String[] args)
{
// Thread Example without lambda
Runnable runnable = new Runnable()
{
@Override
public void run()
{
System.out.println("Thread is running...");
}
};
Thread thread = new Thread(runnable);
thread.start();
}
}
OutputThread is running...
Click the below link to download the code:https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_thread_create_App.zip?attredirects=0&d=1
No comments:
Post a Comment