org.apache.ignite.internal.util

## Class GridBusyLock

- java.lang.Object
- - org.apache.ignite.internal.util.GridBusyLock

    @GridToStringExclude
    public class GridBusyLock
    extends Object

Synchronization aid to track "busy" state of a subsystem that owns it.

For example, there may be a manager that have different threads for some purposes and the manager must not be stopped while at least a single thread is in "busy" state. In this situation each thread must enter to "busy" state calling method `enterBusy()` in critical pieces of code which, i.e. use grid kernal functionality, notifying that the manager and the whole grid kernal cannot be stopped while it's in progress. Once the activity is done, the thread should leave "busy" state calling method `leaveBusy()`. The manager itself, when stopping, should call method `block()` that blocks till all activities leave "busy" state.

### Constructor Summary

Constructors
Constructor and Description
`GridBusyLock()`

### Method Summary

Methods
`void` `block()` Blocks current thread till all activities left "busy" state and prevents them from further entering to "busy" state.
`boolean` `blockedByCurrentThread()` Checks if busy lock was blocked by current thread.
`boolean` `enterBusy()` Enters "busy" state.
`void` `leaveBusy()` Leaves "busy" state.
`void` `unblock()` Makes possible for activities entering busy state again.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### GridBusyLock

    public GridBusyLock()

### Method Detail

#### enterBusy

    public boolean enterBusy()

Enters "busy" state.

Returns:
  `true` if entered to busy state.

#### blockedByCurrentThread

    public boolean blockedByCurrentThread()

Checks if busy lock was blocked by current thread.

Returns:
  `True` if busy lock was blocked by current thread.

#### leaveBusy

    public void leaveBusy()

Leaves "busy" state.

#### block

    public void block()

Blocks current thread till all activities left "busy" state and prevents them from further entering to "busy" state.

#### unblock

    public void unblock()

Makes possible for activities entering busy state again.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.9.0
Release Date | : March 2 2017