Java Concurrency
-
Topic covered here are
- Concurrency vs Parallelisim
A process is a group of threads and thread is an smallest unit of execution. Every thread has two data areas i.e. Execution Stack and Program counter register. Execution stack is created when the thread starts, and it stores local variables, method call frames.
A process is a group of threads and thread is an smallest unit of execution. Program counter register Keeps track of the address of the currently executing instruction
Thread shares Heap Memory, Runtime constant pool and Method area
Thread life cycle, Thread th = new Thread(), here the thread object is created but execution is not yet started, when the th.start() method is called thread is elligible to run or running state, when the thread completes or uncaught exception is throw thread state becomes terminated. A running thread can move to BLOCKED, WAITING or SLEEP(TIMED_WAITING) state.
A thread is in the WAITING state when it is waiting indefinitely for another thread to perform a particular action, This occurs when a thread calls Object.wait(), Thread.join(). Object.notify() or Object.notifyAll() signal moves the thread to RUNNABLE state.
A thread is in the BLOCKED state when it is waiting to acquire a lock
Happy blogging!
Comments
Post a Comment