summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2010-05-04 13:32:08 +0200
committerBenoit Foucher <benoit@zeroc.com>2010-05-04 13:32:08 +0200
commitfccffb342a37ad96425dcd0493d00fd29af407e7 (patch)
treebbddae5e5d99434a302ad8b299a34c7e223d3f6c /java/src
parentbug 4719 - asynchronous end_ method not exported (diff)
downloadice-fccffb342a37ad96425dcd0493d00fd29af407e7.tar.bz2
ice-fccffb342a37ad96425dcd0493d00fd29af407e7.tar.xz
ice-fccffb342a37ad96425dcd0493d00fd29af407e7.zip
bug 4734 - race condition in Java thread pool shrinking code
Diffstat (limited to 'java/src')
-rw-r--r--java/src/IceInternal/ThreadPool.java27
1 files changed, 13 insertions, 14 deletions
diff --git a/java/src/IceInternal/ThreadPool.java b/java/src/IceInternal/ThreadPool.java
index cb99614fc64..d8824831f2b 100644
--- a/java/src/IceInternal/ThreadPool.java
+++ b/java/src/IceInternal/ThreadPool.java
@@ -544,17 +544,18 @@ public final class ThreadPool
//
// Wait to be promoted and for all the IO threads to be done.
//
- while(!_promote || _inUseIO == _sizeIO || _nextHandler.hasNext() && _inUseIO > 0)
+ while(!_promote || _inUseIO == _sizeIO || !_nextHandler.hasNext() && _inUseIO > 0)
{
- while(true)
+ try
{
- try
+ if(_threadIdleTime > 0)
{
- if(_threadIdleTime > 0)
+ long before = IceInternal.Time.currentMonotonicTimeMillis();
+ wait(_threadIdleTime * 1000);
+ if(IceInternal.Time.currentMonotonicTimeMillis() - before >= _threadIdleTime * 1000)
{
- long before = IceInternal.Time.currentMonotonicTimeMillis();
- wait(_threadIdleTime * 1000);
- if(IceInternal.Time.currentMonotonicTimeMillis() - before >= _threadIdleTime * 1000)
+ if(!_destroyed && (!_promote || _inUseIO == _sizeIO ||
+ (!_nextHandler.hasNext() && _inUseIO > 0)))
{
if(_instance.traceLevels().threadPool >= 1)
{
@@ -567,17 +568,15 @@ public final class ThreadPool
return true;
}
}
- else
- {
- wait();
- }
-
- break;
}
- catch(InterruptedException ex)
+ else
{
+ wait();
}
}
+ catch(InterruptedException ex)
+ {
+ }
}
current._leader = true; // The current thread has become the leader.
_promote = false;