Monday, 3 June 2013

What is a thread in java ?

see more post :
Non Runnable States in Multithreading - Different states while thread is in runnable states

A thread is a lightweight process.While dealing with one thread called single thread and with more thread called multi thread.

Main Thread :
When a standalone application is running it is in main thread. What created inside is called  child thread.

Life Cycle Of Thread or States Of Thread :
           New State:
When it is created and is when the thread is not alive ie, before start( ).

           Runnable (ready to run) State:
After invoking start( ) it goes to runnable state.
                        Can return to this state after running, waiting, sleeping or back from blocked state.

           Running State:
This state is at executing state.
           Dead State:
This state begins when run( ) methods completes, from here it will never run again.

           Blocked State:
A thread can enter in this state because of waiting the resources that are hold by another

No comments:

Post a Comment