Package io.javago.sync
Class WaitGroup
java.lang.Object
io.javago.sync.WaitGroup
- All Implemented Interfaces:
 AutoCloseable
The 
WaitGroup class implements Go's sync.WaitGroup.
 A synchronization aid that allows one or more threads to wait until a set of operations being performed in other
 threads completes.
 It implements the AutoCloseable interface and allows a try-with-resources statement to automatically decrease
 its count by one.- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int amount) Increments the count of this wait group by the specified amount.voidawait()Causes the current thread to wait until the count of this wait group reaches zero.voidclose()Decrements the count of this wait group by one.voiddone()Decrements the count of this wait group by one. 
- 
Constructor Details
- 
WaitGroup
public WaitGroup()Constructs a newWaitGroupwith an initial count of zero. 
 - 
 - 
Method Details
- 
add
public void add(int amount) Increments the count of this wait group by the specified amount.- Parameters:
 amount- the amount by which to increment the count
 - 
done
public void done()Decrements the count of this wait group by one. If the count reaches zero, all waiting threads are notified. Equivalent toclose().- Throws:
 IllegalStateException- if the wait group has already reached zero
 - 
await
public void await()Causes the current thread to wait until the count of this wait group reaches zero. If the current count is zero, this method returns immediately. - 
close
public void close()Decrements the count of this wait group by one. If the count reaches zero, all waiting threads are notified. Equivalent todone().- Specified by:
 closein interfaceAutoCloseable- Throws:
 IllegalStateException- if the wait group has already reached zero
 
 -