Java Language / Java ThreadsIt is a light weight process. Program under execution is called as process.1. Extending Thread class. 2. Implementing Runnable Interface Thread Life Cycle It consists of 5 states. They were New – New created Thread will be in a new state. Running - Thread executing will be be in running state. Suspended - Thread executing can be suspended. Blocked - Thread executing can be blocked when waiting for a resource. Terminated - A thread can be terminated will be in terminated state.
Thread Synchronization To avoid thread interference and memory consistency error when 2 / more threads shared resource a common resource java Synchronization method is used.
|