Threads Archive

Static Synchronized Methods

In my previous post, i elaborated object level lock that exist for each instance of a class. We can also use class level lock where all instances of a particular class can share it. As we discussed, any class loaded by java virtual machine has one class level lock. If we make a method static

Synchronized methods and blocks -III

Synchronized Blocks It allows execution of arbitrary code to be synchronized with lock of an arbitrary object. Once a thread reached on synchronized code block after acquiring lock on specified object, other threads will not be able to execute code block or any code requiring same object lock until it is not released by current

Threads in Java – Part II

Different thread states A thread can be in a different states. once thread’s start() method has been called it does not mean that a thread will start working right away. Several factor determines thread working order and transition. Following are common threads states. Ready to run state : thread starts life in ready to run

Threads in Java – Part I

Overview of Threads Software applications are single / multi threaded. A traditional or heavyweight process has a single thread of control. A process with multiple threads of control can perform more tasks at a time. Modern software packages are multi threaded. Such as a browser might have one thread to display text or images while