Multithreading
Creating a thread
Two ways-
Implement the run()
method -> this is the code which will get executed when the thread runs.
Executing Threads
-
Call
start()
methodThe part after start method call is executed immediately. If you want to execute some part of the code after the thread execution, use
join()
method.Thread thread = new ApnaThread(); thread.start(); //this part gets executed immediately after start() is called - while the thread is running thread.join(); //this part gets executed after the thread execution is completed.
-
Use ExecutorService
Children
Backlinks