• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Limitation on number of threads

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone know if there is any limitation on how many threads can run in a JVM? I think there is only limitation on the availale memory. Can someone confirm that?
Thanks.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no hard limit, but typically a JVM will start to buckle somewhere between a few hundred and a few thousand threads, depending on the implementation.
  • Green threads emulate "real" threads using an unprivileged code library. They can be less efficient, are usually more prone to thread starvation, and won't make proper use of multi-CPU machines. One operating system thread is mapped to n Java threads.
  • Native threads use the operating system's threading support. They are generally pre-emptive, reasonably efficient, and make use of multiple CPUs. But they are dependent on the efficiency of the OS's threading implementation. n operating system threads map to n Java threads.
  • A highly tuned server JVM like JRockit combines the two threading types outlined above, mapping n operating system threads to m Java threads (m > n). This allows it to handle thousands of threads without breaking into a sweat.
  • It is difficult to make sweeping statements about the relative merits of these threading implementations - there are too many variables. For hard information, check out The Volano report, especially the network scalability test (which is primarily governed by threading behaviour).
    Last but not least, I'd like to mention v1.4 of the J2SDK, currently in beta, which introduces a new non-blocking I/O architecture (java.nio.*). This allows servers to handle more than one client per thread which should improve scalability a great deal (in a sense it gives you the n:m behaviour of JRockit).
    - Peter

    [This message has been edited by Peter den Haan (edited October 27, 2001).]
reply
    Bookmark Topic Watch Topic
  • New Topic