Wednesday, December 24, 2008

Deadlock

While synchronizing two or more threads, care should be taken to ensure that they don’t create a deadlock situation. This happens when one thread wais for a second thread to pass control, but the second thread in turn waits for the first thread to pass control. When this happens, program execution will simply halt. This situation is called as deadlock. One way to avoid deadlock situation is by making one of the thread to release control for a short time, so that the other synchronized thread can access the common object.

Java

Java is an object oriented programming a language. As the name indicates, objects are the fundamental units of such programming languages. Every object has a state and behavior associated with it. The state of the object is the variables and constants associated with the objects. Behavior is the action that can be performed by the object. This behavior is represented in programs by sequence of statements that perform a specific task. They are also known as methods. So, objects consist of constants, variables and methods. At higher level, every object is created from a prototype called class.