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

Sébastien Bocq sebastien.bocq at gmail.com
Wed Mar 7 14:46:58 EST 2012


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



More information about the Concurrency-interest mailing list