VOOZH about

URL: https://www.geeksforgeeks.org/java/how-to-create-thread-using-lambda-expressions-in-java/

⇱ How to Create Thread using Lambda Expressions in Java? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Create Thread using Lambda Expressions in Java?

Last Updated : 23 Jul, 2025

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:

  • Create the Runnable interface reference and write the Lambda expression for the run() method.
  • Create a Thread class object passing the above-created reference of the Runnable interface since the start() method is defined in the Thread class its object needs to be created.
  • Invoke the start() method to run the thread.

Examples

Example 1:


Output
myThread is running

Example 2: 

Multithreading-1 using lambda expressions


Output
Running common task by Thread-1
Running common task by Thread-0

Example 3: 

Multithreading-2 using lambda expressions


Output
Believer track started
GTA-V5 game started
Believer track ended
GTA-V5 game ended
Comment
Article Tags:
Article Tags: