Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

Multithreaded Sleeping in a single Instance

Thread view: 
James - 29 Mar 2006 10:42 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
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.