Shut down harvester thread pool when it's done. (#223)
* Shut down harvester thread pool when it's done. * Use ExecutorService to create harvester threads; name thread pool threads to match other ice4j threads.
This commit is contained in:
parent
34c2ce50ec
commit
5a299cd694
@ -17,6 +17,7 @@ package org.ice4j.ice.harvest;
|
||||
|
||||
import org.ice4j.*;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.jitsi.utils.concurrent.*;
|
||||
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
@ -283,8 +284,11 @@ public class MappingCandidateHarvesters
|
||||
|
||||
// Now run discover() on all created harvesters in parallel and pick
|
||||
// the ones which succeeded.
|
||||
ExecutorService es = Executors.newFixedThreadPool(tasks.size());
|
||||
ExecutorService es = ExecutorFactory.createFixedThreadPool(tasks.size(),
|
||||
"ice4j.Harvester-executor-");
|
||||
|
||||
try
|
||||
{
|
||||
List<Future<StunMappingCandidateHarvester>> futures;
|
||||
try
|
||||
{
|
||||
@ -312,13 +316,17 @@ public class MappingCandidateHarvesters
|
||||
{
|
||||
// The harvester failed for some reason, discard it.
|
||||
}
|
||||
catch(InterruptedException ie)
|
||||
catch (InterruptedException ie)
|
||||
{
|
||||
Thread.currentThread().interrupt();
|
||||
throw new RuntimeException(ie);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
es.shutdown();
|
||||
}
|
||||
return stunHarvesters;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user