Thread Local

Thread Local Thread Local can be considered as a thread scope. You can set any object in Thread Local and this object will be global and local to the specific thread which is accessing this object. Values stored in Thread Local are global to the thread, meaning that they can…

Continue reading

Race condition in Java multi-threading

Race condition occurs in a multi-threaded environment when more than one thread try to access a shared resource (modify, write) at the same time. Note that it is safe if multiple threads are trying to read a shared resource as long as they are not trying to change it. Since…

Continue reading

Life Cycle of a Thread

  Life Cycle States : 1.New State: A thread has been created but not started yet. A thread will be started by calling its start() method. 2.Runnable State: This state is also called ready to run stage also called queue. A thread starts in runnable state by calling start() method.…

Continue reading

Java Multi-Threading

Multithreading in java is a process of executing multiple threads simultaneously. Thread is basically a lightweight sub-process, a smallest unit of processing. Multiprocessing and multithreading, both are used to achieve multitasking. But we use multithreading than multiprocessing because threads share a common memory area. They don’t allocate separate memory area…

Continue reading