We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 54cf345 commit 100bf93Copy full SHA for 100bf93
virtualthreads-structuredconcurrency.md
@@ -1935,15 +1935,15 @@ void main() throws Exception {
1935
1936
class ConnectionPool {
1937
private final Semaphore semaphore;
1938
- private int connectionId = 0;
+ private final java.util.concurrent.atomic.AtomicInteger connectionId = new java.util.concurrent.atomic.AtomicInteger(0);
1939
1940
ConnectionPool(int size) {
1941
this.semaphore = new Semaphore(size);
1942
}
1943
1944
Connection acquire() throws InterruptedException {
1945
semaphore.acquire();
1946
- return new Connection(++connectionId, this);
+ return new Connection(connectionId.incrementAndGet(), this);
1947
1948
1949
void release() {
0 commit comments