Index: java/org/apache/tomcat/util/net/AprEndpoint.java =================================================================== --- java/org/apache/tomcat/util/net/AprEndpoint.java (revision 929912) +++ java/org/apache/tomcat/util/net/AprEndpoint.java (working copy) @@ -1017,18 +1017,17 @@ */ protected Worker getWorkerThread() { // Allocate a new worker thread - Worker workerThread = createWorkerThread(); - while (workerThread == null) { - try { - synchronized (workers) { + synchronized (workers) { + Worker workerThread; + while ((workerThread = createWorkerThread()) == null) { + try { workers.wait(); + } catch (InterruptedException e) { + // Ignore } - } catch (InterruptedException e) { - // Ignore } - workerThread = createWorkerThread(); + return workerThread; } - return workerThread; } Index: java/org/apache/tomcat/util/net/JIoEndpoint.java =================================================================== --- java/org/apache/tomcat/util/net/JIoEndpoint.java (revision 929912) +++ java/org/apache/tomcat/util/net/JIoEndpoint.java (working copy) @@ -752,18 +752,17 @@ */ protected Worker getWorkerThread() { // Allocate a new worker thread - Worker workerThread = createWorkerThread(); - while (workerThread == null) { - try { - synchronized (workers) { + synchronized (workers) { + Worker workerThread; + while ((workerThread = createWorkerThread()) == null) { + try { workers.wait(); + } catch (InterruptedException e) { + // Ignore } - } catch (InterruptedException e) { - // Ignore } - workerThread = createWorkerThread(); + return workerThread; } - return workerThread; } Index: java/org/apache/tomcat/util/net/NioEndpoint.java =================================================================== --- java/org/apache/tomcat/util/net/NioEndpoint.java (revision 929912) +++ java/org/apache/tomcat/util/net/NioEndpoint.java (working copy) @@ -1218,19 +1218,17 @@ */ protected Worker getWorkerThread() { // Allocate a new worker thread - Worker workerThread = createWorkerThread(); - while (workerThread == null) { - try { - synchronized (workers) { - workerThread = createWorkerThread(); - if ( workerThread == null ) workers.wait(); + synchronized (workers) { + Worker workerThread; + while ((workerThread = createWorkerThread()) == null) { + try { + workers.wait(); + } catch (InterruptedException e) { + // Ignore } - } catch (InterruptedException e) { - // Ignore } - if ( workerThread == null ) workerThread = createWorkerThread(); + return workerThread; } - return workerThread; }