![]() |
VOOZH | about |
Lambda Expressions are introduced in Java SE8. These expressions are developed for Functional Interfaces. A functional interface is an interface with only one abstract method. To know more about Lambda Expressions click here.
Syntax:
(argument1, argument2, .. argument n) -> {
// statements
};
Here we make use of the Runnable Interface. As it is a Functional Interface, Lambda expressions can be used. The following steps are performed to achieve the task:
Example 1:
myThread is running
Example 2:
Multithreading-1 using lambda expressions
Running common task by Thread-1 Running common task by Thread-0
Example 3:
Multithreading-2 using lambda expressions
Believer track started GTA-V5 game started Believer track ended GTA-V5 game ended