@@ -701,7 +701,6 @@ private static void runWithConcurrency(
701701 return ;
702702 }
703703
704-
705704 System .out .println ("[ParallelUtil#runWithConcurrency] submit more tasks" );
706705 // submit all remaining tasks
707706 int tries = 0 ;
@@ -719,7 +718,7 @@ private static void runWithConcurrency(
719718 }
720719 if (!completionService .trySubmit (ts ) && !completionService .hasTasks ()) {
721720 if (++tries >= maxWaitRetries ) {
722- System .out .println ("[ParallelUtil#runWithConcurrency] exceeded max wait retriesS " );
721+ System .out .println ("[ParallelUtil#runWithConcurrency] exceeded max wait retries " );
723722 break ;
724723 }
725724 LockSupport .parkNanos (waitNanos );
@@ -890,6 +889,7 @@ protected void done() {
890889 pool = (ThreadPoolExecutor ) executor ;
891890 availableConcurrency = pool .getCorePoolSize ();
892891 int capacity = Math .max (targetConcurrency , availableConcurrency ) + 1 ;
892+ System .out .println ("[ParallelUtil#runWithConcurrency] capacity = " + capacity + " [target:" + targetConcurrency + ",available:" + availableConcurrency + "]" );
893893 completionQueue = new ArrayBlockingQueue <>(capacity );
894894 } else {
895895 pool = null ;
@@ -937,11 +937,13 @@ void cancelAll() {
937937 }
938938
939939 private boolean canSubmit () {
940- int activeCount = pool . getActiveCount () ;
941- boolean canSubmit = pool == null || activeCount < availableConcurrency ;
940+ int activeCount = 0 ;
941+ boolean canSubmit = pool == null || ( activeCount = pool . getActiveCount ()) < availableConcurrency ;
942942
943943 if (!canSubmit ) {
944944 System .out .println ("[ParallelUtil#runWithConcurrency] unable to submit task and pool:" + pool + ", activeCount:" + activeCount + ", availableConcurrency:" + availableConcurrency );
945+ } else {
946+ System .out .println ("[ParallelUtil#runWithConcurrency] submitted task and pool:" + pool + ", activeCount:" + activeCount + ", availableConcurrency:" + availableConcurrency );
945947 }
946948
947949 return canSubmit ;
@@ -996,6 +998,7 @@ public T next() {
996998
997999 void pushBack (T element ) {
9981000 if (pushedElement != null ) {
1001+ System .out .println ("[ParallelUtil#runWithConcurrency] unable to reschedule task" );
9991002 throw new IllegalArgumentException ("Cannot push back twice" );
10001003 }
10011004 pushedElement = element ;
0 commit comments