public final class

BlockingCounter

extends Object
java.lang.Object
   ↳ com.atlassian.jira.util.concurrent.BlockingCounter

Class Overview

A simple counter that can will cause threads calling the await() method to block while its value is > 0. The counter may only be incremented and decremented and must have a value >= 0.

Summary

Public Constructors
BlockingCounter()
BlockingCounter(int count)
Public Methods
void await()
Block while counter is > 0, throwing InterruptedException if interrupted.
boolean await(long timeout, TimeUnit unit)
void awaitUninterruptibly()
Block while counter is > 0, ignoring interrupts.
void down()
int getCount()
String toString()
void up()
boolean wouldBlock()
Returns true if calling await() at the same very moment would block.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public BlockingCounter ()

public BlockingCounter (int count)

Public Methods

public void await ()

Block while counter is > 0, throwing InterruptedException if interrupted.

Note the behaviour has changed since v6.1 - before that InterruptedException was never thrown due to a bug.

public boolean await (long timeout, TimeUnit unit)

public void awaitUninterruptibly ()

Block while counter is > 0, ignoring interrupts.

See Also
  • AbstractQueuedSynchronizer#doAcquireShared(int)

public void down ()

public int getCount ()

public String toString ()

public void up ()

public boolean wouldBlock ()

Returns true if calling await() at the same very moment would block.

Returns
  • true when count is > 0 so await() would block