summaryrefslogtreecommitdiff
path: root/java-compat/src
diff options
context:
space:
mode:
Diffstat (limited to 'java-compat/src')
-rw-r--r--java-compat/src/Ice/src/main/java/IceInternal/FactoryACMMonitor.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/java-compat/src/Ice/src/main/java/IceInternal/FactoryACMMonitor.java b/java-compat/src/Ice/src/main/java/IceInternal/FactoryACMMonitor.java
index 79cb7b200ef..901491f966d 100644
--- a/java-compat/src/Ice/src/main/java/IceInternal/FactoryACMMonitor.java
+++ b/java-compat/src/Ice/src/main/java/IceInternal/FactoryACMMonitor.java
@@ -57,8 +57,42 @@ class FactoryACMMonitor implements ACMMonitor
{
return;
}
+
+ if(!_connections.isEmpty())
+ {
+ //
+ // Cancel the scheduled timer task and schedule it again now to clear the
+ // connection set from the timer thread.
+ //
+ assert(_future != null);
+ _future.cancel(false);
+ _future = null;
+
+ _instance.timer().schedule(new Runnable() {
+ @Override
+ public void run()
+ {
+ monitorConnections();
+ }
+ }, 0, java.util.concurrent.TimeUnit.MILLISECONDS);
+ }
+
_instance = null;
_changes.clear();
+
+ //
+ // Wait for the connection set to be cleared by the timer thread.
+ //
+ while(!_connections.isEmpty())
+ {
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
}
@Override
@@ -72,6 +106,7 @@ class FactoryACMMonitor implements ACMMonitor
synchronized(this)
{
+ assert(_instance != null);
if(_connections.isEmpty())
{
_connections.add(connection);
@@ -168,6 +203,7 @@ class FactoryACMMonitor implements ACMMonitor
if(_instance == null)
{
_connections.clear();
+ notify();
return;
}