diff --git a/src/org/ice4j/ice/harvest/MultiplexingTcpHostHarvester.java b/src/org/ice4j/ice/harvest/MultiplexingTcpHostHarvester.java
index e7e7a95..59bdfa9 100644
--- a/src/org/ice4j/ice/harvest/MultiplexingTcpHostHarvester.java
+++ b/src/org/ice4j/ice/harvest/MultiplexingTcpHostHarvester.java
@@ -385,6 +385,15 @@ public class MultiplexingTcpHostHarvester
mappedPorts.add(port);
}
+ /**
+ * Triggers the termination of the threads of this
+ * MultiplexingTcpHarvester.
+ */
+ public void close()
+ {
+ close = true;
+ }
+
/**
* Creates and returns the list of LocalCandidates which are to be
* added by this MultiplexingTcpHostHarvester to a specific
@@ -645,6 +654,7 @@ public class MultiplexingTcpHostHarvester
throws IOException
{
setName("MultiplexingTcpHostHarvester AcceptThread");
+ setDaemon(true);
selector = Selector.open();
for (ServerSocketChannel channel : serverSocketChannels)
@@ -894,12 +904,6 @@ public class MultiplexingTcpHostHarvester
private final List channels
= new LinkedList();
- /**
- * Selector used to detect when one of {@link #channels} is
- * ready to be read from.
- */
- private final Selector selector;
-
/**
* Initializes a new ReadThread.
*
@@ -909,12 +913,12 @@ public class MultiplexingTcpHostHarvester
throws IOException
{
setName("MultiplexingTcpHostHarvester ReadThread");
- selector = MultiplexingTcpHostHarvester.this.readSelector;
+ setDaemon(true);
}
/**
* Adds the channels from {@link #newChannels} to {@link #channels} and
- * registers them in {@link #selector}.
+ * registers them in {@link #readSelector}.
*/
private void checkForNewChannels()
{
@@ -925,7 +929,7 @@ public class MultiplexingTcpHostHarvester
try
{
channel.configureBlocking(false);
- channel.register(selector, SelectionKey.OP_READ);
+ channel.register(readSelector, SelectionKey.OP_READ);
}
catch (IOException ioe)
{
@@ -1308,7 +1312,7 @@ public class MultiplexingTcpHostHarvester
try
{
- readyChannels = selector.select(READ_TIMEOUT / 2);
+ readyChannels = readSelector.select(READ_TIMEOUT / 2);
}
catch (IOException ioe)
{
@@ -1317,7 +1321,7 @@ public class MultiplexingTcpHostHarvester
if (readyChannels > 0)
{
- selectedKeys = selector.selectedKeys();
+ selectedKeys = readSelector.selectedKeys();
for (SelectionKey key : selectedKeys)
{
if (key.isReadable())
@@ -1365,7 +1369,7 @@ public class MultiplexingTcpHostHarvester
try
{
- selector.close();
+ readSelector.close();
}
catch (IOException ioe)
{}