Home  >  Article  >  Java  >  What is Java thread deadlock?

What is Java thread deadlock?

王林
王林forward
2023-04-27 13:52:071183browse

1. Description

Thread lock means that the waiting thread has been in a non-running state because the conditions required to wake it up can never be established, or other threads cannot wake up this thread ( The thread has not terminated) causing its task to be unable to progress.

2. Thread locks are divided into two types:

(1) Signal loss lock: Signal loss lock is because there is no corresponding notification thread to wait The thread wakes up, causing the waiting thread to remain in a waiting state.

A typical example is that the waiting thread does not judge the protection condition before executing Object.wait()/Condition.await(). At this time, the protection condition may actually have been established, and there may be no other thread updates thereafter. The shared variables involved in the corresponding protection conditions are established and the waiting thread is notified. This keeps the waiting thread in a waiting state, making its task unable to progress.

(2) Nested monitor lockup: Nested monitor lockup is a fault in which the waiting thread can never be awakened due to nested locks.

For example, a thread only releases the inner lock Y.wait(), but does not release the outer lock X; but the notification thread must first obtain the outer lock X before it can use Y.notifyAll() Wake up the waiting thread, which leads to the phenomenon of nested waiting.

What are the basic data types of java

The basic data types of Java are divided into:

1. Integer type, used to represent the data type of integer.

2. Floating point type, a data type used to represent decimals.

3. Character type. The keyword of character type is "char".

4. Boolean type is the basic data type that represents logical values.

The above is the detailed content of What is Java thread deadlock?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete