* @param to endpoint to which we need to stream the file.
*/
public void stream(StreamHeader header, InetAddress to)
{
DebuggableThreadPoolExecutor executor = streamExecutors.get(to);
if (executor == null)
{
// Using a core pool size of 0 is important. See documentation of streamExecutors.
executor = DebuggableThreadPoolExecutor.createWithMaximumPoolSize("Streaming to " + to, 1, 1, TimeUnit.SECONDS);
DebuggableThreadPoolExecutor old = streamExecutors.putIfAbsent(to, executor);
if (old != null)
{
executor.shutdown();
executor = old;
}