[concurrency-interest] Executors.newCachedThreadPool()

Rohit Reja rreja2000 at yahoo.com
Thu Jun 5 01:56:51 EDT 2014


Why does the default implementation of Executors.newCachedThreadPool() has Integer.MAX_VALUE as the upper limit for number of threads?
If I use this default implementation, don't I  risk  creating a lot of threads when a burst of tasks gets scheduled and JVM running out of stack memory?

What is recommended?

Rohit Reja

On Thursday, June 5, 2014 1:52 AM, Vitaly Davidovich <vitalyd at gmail.com> wrote:

If you had multiple writers publishing a reference, lazySet won't work - you'd need a CAS loop (or locking, depending on expected contention/conflict rate).
Sent from my phone
On Jun 4, 2014 3:13 PM, "vikas" <vikas.vksingh at gmail.com> wrote:

>>On Fri, Nov 29, 2013 at 6:51 AM, Nitsan Wakart <[hidden email]> wrote:
>>>From my experience, lazySet is indeed your best choice (but only a valid
>choice for a single writer). You >>need a volatile read to match the HB
>relationship otherwise the compiler is free to optimize the value you
>>>read, so someone using your map in a loop may end up stuck if you don't do
>Hi Nitsan,
>   Why you said lazySet is a valid choice for single writer. Can you give
>any reference or example on what can go wrong with multiple writers.
>>> You hopefully meant StoreStore | LoadStore .  Otherwise we have a very
>>> subtle but serious problem.  >>(See
>>> *http://www.hpl.hp.com/personal/Hans_Boehm/c++mm/no_write_fences.html
>>> *for a C++ discussion >>from a few years ago.)
>Hi Hans,
>  The link you provided is no more valid. Can you please provide the fresh
>View this message in context: http://jsr166-concurrency.10961.n7.nabble.com/Single-writer-multiple-readers-no-barriers-safe-tp10306p11048.html
>Sent from the JSR166 Concurrency mailing list archive at Nabble.com.
>Concurrency-interest mailing list
>Concurrency-interest at cs.oswego.edu

Concurrency-interest mailing list
Concurrency-interest at cs.oswego.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20140604/f33642d7/attachment.html>

More information about the Concurrency-interest mailing list