[Javagroups-development] jgroups threads and exceptions
Brought to you by:
belaban
From: Bruce S. <bsc...@gm...> - 2006-01-18 18:23:20
|
Since there can be a lot of threads in a JGroups stack, it might be useful to put them in one or more thread groups to better control them. One thing that I often do with this is implement uncaughtException in the thread group so I can see why a thread died. For instance, in Util there could be a static threadgroup: /** * ThreadGroup to which JGroups threads belong */ private static ThreadGroup GROUP = new ThreadGroup("JGroups Threads") { public void uncaughtException(Thread t, Throwable e) { StringWriter sw = new StringWriter(); sw.write("uncaught exception in thread "); sw.write(t.getName()); LogFactory.getLog(JChannel.class).error("ThreadGroup: " + sw.toString(), e); } }; public static ThreadGroup getThreadGroup() { return GROUP; } and then, in Protocol and other places, use the group in creating threads public UpHandler(...) { super(Util.getThreadGroup(), "tempname"); this.mq=mq; etc. |