0
Explain Life cycle of thread?
Java, life cycle of thread...
4 Respostas
+ 8
start is the initial state / method. run the state / method where the thread stays all time until it returns from there by a certain condition (you can check a bool variable in a loop for example), when it returns from run, the thread is stopped. Don't use the stop or suspend methods! They are not safe.
For the other states / actions, see
https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html
You might check the methods wait() and interrupt() for your block action. As well as join() for synchronisation.
Runnable is not a state, but an interface which is implemented by Thread.
To customize your own Runnable or Thread, you can either implement Runnable or extend Thread.
See the Oracle tutorials:
https://docs.oracle.com/javase/tutorial/essential/concurrency/index.html
+ 8
start() -> run() -> does whatever the thread needs to do -> return from run method.
I don't know what exactly you want to know. Any particular questions?
+ 2
@Tashi N
I mean different states like running ,runnable ,block and dead of a thread
+ 1
thank you