public class InProgress extends Object
start
and
stop
on this object when it starts and stops the
operation in progress. The thread that wants to block itself while
the operation is in progress invokes waitWhileStarted
,
which will block if start
has been invoked without a
matching stop
. The block will continue until a
matching stop
is invoked. Each start
adds
one to the number of operations; each stop
subtracts
one. When the number of operations is zero, the operation bounded
by this object is not in progress, and waitWhileStarted
will return.
The operation can also be blocked by invoking block
and
unblock
, which nest like start
and
stop
. When a block
is invoked on this
object, no start
will proceed until the matching
unblock
call is made. The reverse is also true: when a
stop
call has been made on this object, no
block
call will proceed until the matching
stop
call is made. A waitUntilUnblocked
method allows selective waiting for the unblocked state without
invoking start
.
A waitUntilQuiet
call waits until the object is neither
blocked nor stopped.
Constructor and Description |
---|
InProgress(String name) |
Modifier and Type | Method and Description |
---|---|
void |
block()
Signal the blocking of the operation this object bounds.
|
boolean |
blocked()
Return
true if at least one block has been
invoked without its corresponding unblock . |
void |
debug(boolean debugOn)
Set the debug mode on or off.
|
boolean |
inProgress()
Return
true if at least one start has been
invoked without its corresponding stop . |
void |
start()
Signal the start of the operation this object bounds.
|
void |
stop()
Signal the stop of the operation this object bounds.
|
void |
unblock()
Signal the unblocking of the operation this object bounds.
|
void |
waitUntilQuiet()
Wait if the operation bounded by this object is either started
or blocked.
|
void |
waitWhileBlocked()
Wait if the operation bounded by this object has been blocked, i.e.,
between a
block and a unblock . |
void |
waitWhileStarted()
Wait if the operation bounded by this object is in progress, i.e.,
between a
start and a stop . |
public InProgress(String name)
public void start() throws InterruptedException
InterruptedException
public void stop()
public boolean inProgress()
true
if at least one start
has been
invoked without its corresponding stop
.public void waitWhileStarted() throws InterruptedException
start
and a stop
.InterruptedException
public void block() throws InterruptedException
InterruptedException
public void unblock()
public boolean blocked()
true
if at least one block
has been
invoked without its corresponding unblock
.public void waitWhileBlocked() throws InterruptedException
block
and a unblock
.InterruptedException
public void waitUntilQuiet() throws InterruptedException
InterruptedException
public void debug(boolean debugOn)
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.