geode-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darrel Schneider <>
Subject creating Thread, ThreadFactory, or Executor instances in geode
Date Sat, 06 Oct 2018 00:54:59 GMT
When a thread runs, if it throws an exception that is not caught, then that
exception will just silently kill your thread. This can make it very hard
to diagnose what is happening. To remedy this situation in geode, a long
time ago it introduced a LoggingThreadGroup class. As long as you created
one of these groups and put your thread in it, then the uncaught exception
would be logged to the geode logger.
One of the problems with LoggingThreadGroup was that it kept a static
collection of all the instances of it. In some places this lead to memory
leak problems. Also geode had many places in its code that forgot to use
this in favor of some other JDK API that created a thread that would not
have a geode LoggingThreadGroup.
Today fixes for GEODE-5780 and GEODE-5783 were done that remove
Now if you want to create a thread use LoggingThread. You can either
directly create an instance of it of subclass it.
If you want a ThreadFactory use LoggingThreadFactory.
If you want an Executor using LoggingExecutors (which even has support for
a work stealing pool which will log).

All of these classes register with any thread they create a singleton
instance of LoggingUncaughtExceptionHandler that will log uncaught
exceptions to a Logger. If you find some other way that you need to create
a thread that can not use LoggingThread, LoggingThreadFactory, or
LoggingExecutors then you should at least register your thread instance
with LoggingUncaughtExceptionHandler by calling the "setOnThread(Thread)"
method on it.

Let me know if you have any questions about how to create threads in geode.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message