A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Difference between t. start and t.run()

What is the difference between start method and run method in Java multithreading?

What is the difference between start() method and run() method in Java multithreading?

  • In the case of t.start() a new thread will be created which is responsible for the execution of run () method.

  • But, in the case of t.run() a new thread will not be created and run() will be executed just like a normal method called by the main method.

  • Hence, in the previous program if we replace t.start() with t.run() then out is as follow:

  • Child thread is running(10 times)

  • the main thread is running(10 times)

  • This total output produced by an only main thread.

LEARN TUTORIALS

.

.