Does anybody know of any issues I should be aware of doing the follow:
In a highly multithreaded J2SE application (1000+ threads), having an
object where 500+ threads share a single instance of a class that
contains a method with a Thread.sleep(n) call in. n will have a
different value for each thread and will be stored in a ThreadLocal
attribute. At any one time approximately half the threads will be
sleeping and half active.
The code needs to run on Windows XP pro, Solaris 10 and Red Hat
(version to be decided).
Any advice warnings of gotchas will be greatly appreciated.
Chris Uppal - 29 Mar 2006 11:51 GMT
> Does anybody know of any issues I should be aware of doing the follow:
> In a highly multithreaded J2SE application (1000+ threads),
Sounds like far too many threads to me. Threads are expensive. What are you
doing with them ?
-- chris
Robert Klemme - 29 Mar 2006 13:46 GMT
>> Does anybody know of any issues I should be aware of doing the follow:
>> In a highly multithreaded J2SE application (1000+ threads),
>
> Sounds like far too many threads to me. Threads are expensive. What are you
> doing with them ?
Especially since half of them are sleeping. Sounds like there could be
a more efficient implementation pattern.
robert
search - 29 Mar 2006 16:03 GMT
better to use timer maybe -:)
> >> Does anybody know of any issues I should be aware of doing the follow:
> >> In a highly multithreaded J2SE application (1000+ threads),
[quoted text clipped - 6 lines]
>
> robert
Alun Harford - 29 Mar 2006 12:03 GMT
> Does anybody know of any issues I should be aware of doing the follow:
> In a highly multithreaded J2SE application (1000+ threads), having an
[quoted text clipped - 8 lines]
>
> Any advice warnings of gotchas will be greatly appreciated.
Threads cost you resources. They need stacks, some memory in kernel mode,
and some memory on the heap. IIRC The default stack size is 256k in Windows
and Unix on x86.
You should avoid using that many threads. (Unless you're planning to run it
on a machine with 1000+ physical processors)
Alun Harford