ctubbsii commented on code in PR #5853:
URL: https://github.com/apache/accumulo/pull/5853#discussion_r2323917948
##########
core/src/test/java/org/apache/accumulo/core/crypto/CryptoTest.java:
##########
@@ -539,14 +540,18 @@ private void testMultipleThreads(Scope scope) throws
Exception {
var executor = Executors.newCachedThreadPool();
- List<Future<Boolean>> verifyFutures = new ArrayList<>();
+ final int numTasks = 32;
+ List<Future<Boolean>> verifyFutures = new ArrayList<>(numTasks);
+ CountDownLatch startLatch = new CountDownLatch(numTasks);
Review Comment:
Perhaps a simpler implementation would be to make the countdownlatch not
depend on the number of tasks.
You can just set it to 1 initially, have all tasks await, then tell it to
countDown after the for loop that submits them all. That is equivalent to
having them all line up at the starting line, and toggling from red to green to
say "Go". You only need two signals 1 ("don't go yet") and 0 ("go!"). You don't
actually have to have them count down each time they are submitted, since you
don't need numTasks number of signals.
The way it is now, you could actually hit a problem... if the executor
doesn't have enough threads to run them all concurrently, the countdown will
never reach 0 and you'll be deadlocked. So, you've really got to be sure you
have enough threads the current way you have it implemented. In my suggestion,
it won't require numTasks number of threads.... but will start concurrently all
the tasks that have been able to be started, even if it's less than the total.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]