creating my own ThreadFactory

Hi

We would like our ThreadPoolExecutor to schedule threads within DIFFERENT ThreadGroups.

In order to allow this we need to create our own ThreadFactory instead of using the default Executors.defaultThreadFactory().

So we implement something like this:

class SimpleThreadFactory implements ThreadFactory {

ThreadGroup myThreadGroup = new ThreadGroup("myGroupName");

public Thread newThread(myThreadGroup Runnable r) {

return new Thread(r);

}

}

However we feel this will lead to unexpected results because our ThreadFactory will lack the default/usefull values set inExecutors.defaultThreadFactory().

Is this correct?

thanks

John

[715 byte] By [John49a] at [2007-11-26 17:41:08]
# 1
All it does ensure the thread is a non-daemon, and has NORM_PRIORITY and a legible unique name. It also uses the thread group of the security manager if there is one but you want to change that anyway.
ejpa at 2007-7-9 0:09:19 > top of Java-index,Core,Core APIs...
# 2

The actions of the default factory are well specified so as ejp states just add the same settings to your factory. If worried about the defaults changing (they wont!) use a Thread from the default factory as a template and store the daemon/priority values. You'll probably also want to set useful names.

davidholmesa at 2007-7-9 0:09:19 > top of Java-index,Core,Core APIs...
# 3
Thanks for your answers.John
John49a at 2007-7-9 0:09:19 > top of Java-index,Core,Core APIs...