wcarlson5 commented on a change in pull request #9887:
URL: https://github.com/apache/kafka/pull/9887#discussion_r557739729



##########
File path: streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java
##########
@@ -989,16 +989,20 @@ private StreamThread createAndAddStreamThread(final long 
cacheSizePerThread, fin
     public Optional<String> removeStreamThread() {
         if (isRunningOrRebalancing()) {
             synchronized (changeThreadCount) {
-                for (final StreamThread streamThread : threads) {
-                    if (streamThread.isAlive() && 
(!streamThread.getName().equals(Thread.currentThread().getName()) || 
threads.size() == 1)) {
-                        streamThread.shutdown();
-                        if 
(!streamThread.getName().equals(Thread.currentThread().getName())) {
-                            
streamThread.waitOnThreadState(StreamThread.State.DEAD);
+                synchronized (threads) {

Review comment:
       Why are we using the threads object as a lock here? is that was the 
`Collections.synchronizedList(new LinkedList<>());` uses internally?
   
   I am a little concerned that we are holding `changeThreadCount` while 
waiting for `threads`




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to