This is actually a lock. If self is accessed by other threads, it will be blocked. This is generally used to protect a deadlock for a single instance.
@ Synchronized (Self ){
// Something like this
Kgoablevalue = _ your instance;
}
1. When two concurrent threads access the synchronized (Self) synchronization code block of the same object, only one thread can be executed within a time period. The other thread must wait until the current thread finishes executing this code block before executing this code block.
2. When a thread accesses a synchronized (Self) synchronization code block of the object, access by other threads to all other synchronized (Self) synchronization code blocks of the object will be blocked.
3. However, when a thread accesses a synchronized (Self) synchronization code block of an object, the other thread can still access parts of the object except the synchronized (this) synchronization code block.
4. The third example also applies to other synchronous code blocks. That is to say, when a thread accesses a synchronized (this) synchronization code block of an object, it obtains the object lock of this object. As a result, access by other threads to all the synchronized code parts of the object is temporarily blocked.
5. The above rules apply to other Object locks.