* Some changes to logging / server handling.

This commit is contained in:
LevelX2 2014-09-10 17:14:36 +02:00
parent e8f9c0822f
commit ddeb519848
5 changed files with 38 additions and 18 deletions

View file

@ -31,6 +31,7 @@ package mage.server.util;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@ -55,10 +56,13 @@ public class ThreadExecutor {
static {
((ThreadPoolExecutor)callExecutor).setKeepAliveTime(60, TimeUnit.SECONDS);
((ThreadPoolExecutor)callExecutor).allowCoreThreadTimeOut(true);
((ThreadPoolExecutor)callExecutor).setThreadFactory(new XMageThreadFactory("CALL"));
((ThreadPoolExecutor)gameExecutor).setKeepAliveTime(60, TimeUnit.SECONDS);
((ThreadPoolExecutor)gameExecutor).allowCoreThreadTimeOut(true);
((ThreadPoolExecutor)callExecutor).setThreadFactory(new XMageThreadFactory("GAME"));
((ThreadPoolExecutor)timeoutExecutor).setKeepAliveTime(60, TimeUnit.SECONDS);
((ThreadPoolExecutor)timeoutExecutor).allowCoreThreadTimeOut(true);
((ThreadPoolExecutor)callExecutor).setThreadFactory(new XMageThreadFactory("TIME"));
}
private static final ThreadExecutor INSTANCE = new ThreadExecutor();
@ -82,3 +86,18 @@ public class ThreadExecutor {
}
}
class XMageThreadFactory implements ThreadFactory {
private final String prefix;
XMageThreadFactory(String prefix) {
this.prefix = prefix;
}
@Override
public Thread newThread(Runnable r) {
Thread thread = new Thread(r);
thread.setName(prefix + " " + thread.getThreadGroup().getName() + "-" + thread.getId());
return thread;
}
}