users@grizzly.java.net

Re: finding out the available threads in a thread pool

From: Carla Mott <carla.mott_at_oracle.com>
Date: Fri, 10 Sep 2010 11:41:34 -0700

Hi Alexey,

Thanks for the info. I really just want to reduce the likely hood of
there being a deadlock. We think that getting the max size and the
current pool size and if there are at least 40% more available threads
we will go ahead and try the operation is a reasonable measure for us.
I understand that the current number of available threads is dynamic but
that is ok because we don't need the exact number.

It seems from you comments that there is a way to get that number. Is
there an api?

Thanks,
Carla

Oleksiy Stashok wrote:
> Hi Carla,
>
> unfortunately it's not possible to reserve a thread in the thread pool.
> Checking the avail. threads number won't help, cause this value is
> dynamic and could be used just for monitoring stats.
>
> The solution you may want to use - is to create custom thread pool,
> which you'll be able to control within your code, use synchronizations
> etc...
>
> So when HTTP request comes and you realize that it's *the* command -
> you can suspend the request processing in the current thread and pass
> it to the custom thread. Once processing is done - you can resume the
> HTTP processing.
> When saying suspend/resume, I'm referring to the
> GrizzlyResponse.suspend/resume methods.
>
> Hope this will help.
> If you have more questions - please ask.
>
> WBR,
> Alexey.
>
> On Sep 9, 2010, at 23:36 , Carla Mott wrote:
>
>>
>> Hi,
>>
>> I'm writing a command in glassfish and we found that we can
>> potentially end up with a deadlock. The issue is that some commands
>> use 2 threads to complete the operation. When we run the command
>> simultaneously can run into a deadlock.
>> We have increased the size of the pool but doesn't solve the
>> problem. I would like to get the max size and either the number of
>> threads in use or the number available so I can figure out if I
>> should attempt the operation. It seems that the only thing that I'm
>> able to find out is the max poll size number. Is there any way to
>> figure out the info I'm looking for?
>>
>> Thanks,
>> Carla
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>