https://github.com/varunu28/wait-group
:hourglass_flowing_sand: A Java implementation of Golang's wait group interface
https://github.com/varunu28/wait-group
Last synced: 15 days ago
JSON representation
:hourglass_flowing_sand: A Java implementation of Golang's wait group interface
- Host: GitHub
- URL: https://github.com/varunu28/wait-group
- Owner: varunu28
- Created: 2023-07-05T19:01:31.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-06T15:25:02.000Z (over 2 years ago)
- Last Synced: 2025-02-21T17:48:14.714Z (8 months ago)
- Language: Java
- Homepage:
- Size: 3.76 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Wait-Group
A Java implementation of Golang's [WaitGroup](https://pkg.go.dev/sync#WaitGroup) interface
## What does this implementation covers?
- Java implementation for all the methods exposed by `WaitGroup` interface
- `WaitGroup` is reusable as per the interface contract
- Panic exception in case `WaitGroup` counter reaches a negative value## How to use it?
The usage is similar to Golang's interface. The flow looks as below:#### Create a `WaitGroup` instance
```agsl
WaitGroup wg = new WaitGroupImpl();
```
#### Add a delta for number of processes that are running in the background
```
wg.add(delta);
```
#### Each background process marks `WaitGroup` as `done` once it finishes processing
```agsl
void run() {
// some processing
wg.done();
}
```#### Main thread awaits for all the processes to finish
````agsl
wg.wgWait();
````