Package org.opennms.test
Class ThreadLocker
- java.lang.Object
-
- org.opennms.test.ThreadLocker
-
public class ThreadLocker extends Object
This class can be used to verify the number of threads that are calling a particular method. This is achieved by locking all of the threads that callMessageProducer#sendand providing a callback (via aCompletableFuture) that is invoked once the desired number of threads is reached. If a larger number of threads than expected callMessageProducer#send, these are locked as well, and the number of these is provided bygetNumExtraThreadsWaiting().- Author:
- jwhite
-
-
Constructor Summary
Constructors Constructor Description ThreadLocker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetNumExtraThreadsWaiting()voidpark()voidrelease()CompletableFuture<Integer>waitForThreads(int numThreads)
-
-
-
Method Detail
-
waitForThreads
public CompletableFuture<Integer> waitForThreads(int numThreads)
-
park
public void park()
-
release
public void release()
-
getNumExtraThreadsWaiting
public int getNumExtraThreadsWaiting()
-
-