mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-11 17:55:53 +00:00
NioClientManager: use a daemon thread so GUI apps can quit fast if they want to without a slow/hung network thread keeping things hanging around. This may break compatibility with apps that expect to be able to start bitcoinj and then exit the main thread: if it causes too many problems this change may be reverted.
This commit is contained in:
parent
f4cce4c3c0
commit
ad4fb5103c
@ -17,10 +17,7 @@
|
||||
package org.bitcoinj.net;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.util.concurrent.AbstractExecutionThreadService;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.SettableFuture;
|
||||
import com.google.common.util.concurrent.*;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -29,7 +26,7 @@ import java.net.SocketAddress;
|
||||
import java.nio.channels.*;
|
||||
import java.nio.channels.spi.SelectorProvider;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* A class which manages a set of client connections. Uses Java NIO to select network events and processes them in a
|
||||
@ -185,4 +182,16 @@ public class NioClientManager extends AbstractExecutionThreadService implements
|
||||
handler.closeConnection(); // Removes handler from connectedHandlers before returning
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Executor executor() {
|
||||
return new Executor() {
|
||||
@Override
|
||||
public void execute(Runnable command) {
|
||||
Thread thread = new Thread(command, "NioClientManager");
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user