Java Thread Not Created – run() or start() ?

Why is my Java thread not running?

A: Calling run() and start() are not the same.

start() – create a new thread. Now we have one main process and a thread executing concurrently.

run() – no new thread create. The main process go into the class of the thread and executes codes in the run() block. Now we have only one main process in the application.

run() is just a function in the class. start() is to ask the JVM to create a new thread first and uses this newly created thread to execute run() function.

So call start() when you want to create a new thread to execute your code concurrently.

Leave a Reply

Your email address will not be published. Required fields are marked *

eight × = 8