answersLogoWhite

0

What is deadlock in java?

Updated: 8/18/2019
User Avatar

Wiki User

13y ago

Best Answer

A deadlock is a situation that comes up when multiple threads are being used in a single java program. During thread execution, threads can access any number of methods they want. To ensure that data is consistent during execution, the methods have a property called "synchronized" which prevents multiple threads from accessing a single method. So under this scenario lets take a look at this example:

Thread A is currently holding a lock on Method A and needs to execute method B in order to complete.

Thread B is currently holding a lock on Method B and needs to execute method A in order to complete.

The above is a classic example of deadlock.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is deadlock in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the various strategies are used to handle deadlock and what is centralized and distributed deadlock detection and prevention?

There are four strategies of dealing with deadlock problem:1. The Ostrich ApproachJust ignore the deadlock problem altogether.2. Deadlock Detection and RecoveryDetect deadlock and, when it occurs, take steps to recover.3. Deadlock AvoidanceAvoid deadlock by careful resource scheduling.4. Deadlock PreventionPrevent deadlock by resource scheduling so as to negate at least one of the four conditions.


What is an antonym for the word deadlock?

The antonym for deadlock is agreement.


When was Holy Deadlock created?

Holy Deadlock was created in 1934.


When was Deadlock - film - created?

Deadlock - film - was created in 1931.


When was Wedlock Deadlock created?

Wedlock Deadlock was created in 1947.


What are the release dates for House of Dreams - 2004 To Deadlock or Not to Deadlock 1-3?

House of Dreams - 2004 To Deadlock or Not to Deadlock 1-3 was released on: USA: 22 January 2004


How many pages does Holy Deadlock have?

Holy Deadlock has 311 pages.


What are the different method for handling deadlock?

deadlock handling by 2phase protocol


When was Wolves - Deadlock album - created?

Wolves - Deadlock album - was created in 2007.


When was Deadlock - metal band - created?

Deadlock - metal band - was created in 1997.


What is false deadlock?

the coordinator conculde incorrectly that a deadlock exist and kills some process --------------------------- Detecting a non existent deadlock in distributed system has been referred as false deadlock and it may occur due to communication delay.. ---->Ashok Paranjothi


Advantage and disadvantage of deadlock prevention?

The advantage of deadlock prevention is that it installs competition and cost may become. The disadvantage of deadlock prevention is that it takes a significant amount of time to plan for it.