[concurrency-interest] How to set the thread group of theForkJoinPool?

Sébastien Bocq sebastien.bocq at gmail.com
Wed Mar 7 15:51:40 EST 2012


Thank you all for the suffestions, I have enough ideas to work out a
solution now.

Sebastien

Le 7 mars 2012 21:43, David Holmes <davidcholmes at aapt.net.au> a écrit :
> The only way I can see to set the ThreadGroup is for your ThreadFactory to
> use its own thread, which itself is placed in the right group. That thread
> then constructs the ForkJoinWorkerThreads and they inherit the ThreadGroup.
>
> Arguably ForkJoinWorkerThread should expose a constructor that allows any
> Thread parameters to be set (group, name, stack-size)
>
> David
>
>> -----Original Message-----
>> From: concurrency-interest-bounces at cs.oswego.edu
>> [mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of
>> Sébastien Bocq
>> Sent: Thursday, 8 March 2012 5:47 AM
>> To: Romain Colle
>> Cc: concurrency-interest at cs.oswego.edu; Peter Firmstone
>> Subject: Re: [concurrency-interest] How to set the thread group of
>> theForkJoinPool?
>>
>>
>> Le 7 mars 2012 20:40, Romain Colle <rco at quartetfs.com> a écrit :
>> > On Wed, Mar 7, 2012 at 2:28 PM, Sébastien Bocq
>> <sebastien.bocq at gmail.com>
>> > wrote:
>> >>
>> >> I use different pools and I need to identify from which pool threads
>> >> are coming from. For instance, I want to use my own naming scheme.
>> >
>> >
>> > Hi Sebastien,
>> >
>> > We are using a thread factory to do so, and extend ForkJoinWorkerThread.
>> > We simply call "setName" when the thread starts to get the
>> required naming.
>> > See sample code below.
>> >
>> >     protected class Worker extends ForkJoinWorkerThread {
>> >         protected Worker(ForkJoinPool pool) {
>> >             super(pool);
>> >         }
>> >
>> >         /**
>> >          * Called when the thread is started
>> >          */
>> >         protected void onStart() {
>> >             super.onStart();
>> >             setName(poolName + "-" + poolIndex + "-worker-" +
>> > workerCount.getAndIncrement());
>> >         }
>> >     }
>> >
>> > --
>> > Romain Colle
>> > Senior R&D Engineer
>> > QuartetFS
>> > 2 rue Jean Lantier, 75001 Paris, France
>> > http://www.quartetfs.com
>>
>> Hi Romain,
>>
>> Thanks. That is one thing but I need to set my own ThreadGroup as well
>> for other reasons.
>>
>> Sébastien
>>
>> _______________________________________________
>> Concurrency-interest mailing list
>> Concurrency-interest at cs.oswego.edu
>> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>>
>



-- 
Sébastien



More information about the Concurrency-interest mailing list