Skip to content

Commit 7a18f79

Browse files
committed
Added xmemcached.heartbeat.max_threads variable to sizing heartbeat thread pool
1 parent cd90dcd commit 7a18f79

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/main/java/net/rubyeye/xmemcached/impl/MemcachedHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
*/
5858
public class MemcachedHandler extends HandlerAdapter {
5959

60+
private static final int MAX_HEARTBEAT_THREADS = Integer.parseInt(System.getProperty("xmemcached.heartbeat.max_threads", String.valueOf(Runtime.getRuntime().availableProcessors())));
61+
6062
private final StatisticsHandler statisticsHandler;
6163

6264
private ExecutorService heartBeatThreadPool;
@@ -295,7 +297,7 @@ public void start() {
295297

296298
long keepAliveTime = client.getConnector().getSessionIdleTimeout() * 3 / 2;
297299

298-
this.heartBeatThreadPool = new ThreadPoolExecutor(0, Runtime.getRuntime().availableProcessors(),
300+
this.heartBeatThreadPool = new ThreadPoolExecutor(1, MAX_HEARTBEAT_THREADS,
299301
keepAliveTime, TimeUnit.MILLISECONDS,
300302
new SynchronousQueue<Runnable>(),
301303
new ThreadFactory() {

0 commit comments

Comments
 (0)