Javatpoint Logo
Javatpoint Logo

Scala Thread

There are two ways to create a thread:

  1. By extending Thread class
  2. By implementing Runnable interface

Scala Thread Example by Extending Thread Class

The following example extends Thread class and overrides run method. The start() method is used to start thread.

Output:

Thread is running...

Scala Thread Example by Extending Runnable Interface

The following example implements Runnable interface and overrides run method. The start() method is used to start thread.

Output:

Thread is running...




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA