Java: is CountDownLatch threadsafe

In the docs for, CountDownLatchI see something like:

public void run () {
      try {
        startSignal.await ();
        doWork ();
        doneSignal.countDown ();
      } catch (InterruptedException ex) {} // return;
}

Where startSignaland doneSignalare the objects CountDownLatch.

The docs say nothing about whether the class is thread safe or not.

+4
source share
1 answer

Since it is intended to be used by multiple threads, it would be fair to assume that it does not contain threads to most thread safety values.

There is even a random action (from your link ):

: , countDown() () .

, countDown? ? , countDown .

+4

All Articles