Maximum number of threads

I have an application for which I am interested in obtaining as many simultaneous
threads as possble (e.g. 10's and possibly 100's of thousands of threads).
More specifically I have developed a simulation language formalism in which the
dynamics of each "entity" moving through a network of queues is coordinated by
a separate thread of execution.
This is not a traditional application where all or even some small number are
intended to run concurrently. A single executive thread is responsible for alternately
activating and deactivating individual threads to reflect the time ordered sequencing
of events corresponding to each entity's movement through the system of queues.
As a result, only a single thread is executing at one time.
Using a separate thread for each entity off-loads the task of managing each's
execution context to the JVM. The resource contention issues that arise in a
standard multi-threaded application don't apply here.
For "large" systems though (ones populated by many entities simultaneously) I
need many threads.
I'm using JRockit's thin thread model on a Windows XP machine and am "only" able
to get approximately 25000 threads at which point the JVM hangs with no diagnostic.
I say "only" because at that point there seems to be plenty of heap space left
as well as Page File space left in the XP's Virtual Memory system.
I'm using the following JVM command line:
java -Xthinthreads -Xss32K -Xms256M -Xmx256M -Xallocationtype:global
Surprisingly, by altering the heap size upward from 256MB to 512MB acutally causes
the VM to hang with fewer threads (only 20000 or so)
Using allicationtype:global and altering the stack size of the threads seems to
have little effect on the maximum number attainable.
It seems the maximum number of threads attaible should be a function of the size
of the heap space, and the amount of physical and virtual memory limits on the
system.
My empirical evidence, however, seems to indicate there is some internal VM limit.
Can someone explain for me the implementation of the thin thread model and its
limitations w.r.t. the number of threads it can support?
Thanks in advance for you help.

You might try to use the new java.util.concurrent.* api available in j2se
1.5.0 as
a base for your implementation instead.
/Robert
"Staffan Larsen" <[email protected]> wrote in message
news:40f63c6b$1@mktnews1...
The reason for the "artifical" limitation of 32767 is that each thread
needs to have it's own id. The way the object synchonization algorithm
works, there has to be space for this id in the header of each object.
The header has a very limited amount of space (currently 2 words) and
thus there is not space for a larger thread id than 32767.
You may be interested (but sad) to know that the thinthreads model has
been removed from later versions of JRockit. The reason was the overhead
of maintaining and supporting multiple threading systems was just too
much work for a small return. Although, for very specialized systems
(like yours) it would give a higher return.
About your calculation. You said in you first post that you set -Xss32k
which means that each thread will take at least 32k memory, more likey
40k with other overhead. That means about 25 threads per MB or 25000 per
GB, given that everything scales linearly.
Regards,
/Staffan
Kevin Healy wrote:
Staffan,
Thanks for your response. Certainly in a traditional multi-threaded
applications
where there exist many runnable threads competing for resources, thepoint of
diminishing returns is usually on the order of 10's of threads; but, asI mentioned,
this is not a traditional application. In this case, the threadingframework
is used as a natural and convenient way to manage the execution contextof the
(many) entities in the system. Since I'm not interested in trueconcurrency or
exploiting parallelism, I view threads as just data and it strikes methat I should
be able to get as many as I have room for. In fact the green threadsmodel of
the pre JDK 1.4 JVM's was well-suited to this kind of application but itseems
the JVM implementors have not considered this in removing support forgreen threads
in their newest releases. The thin threads model of JRockit is the nextbest
thing but the 32767 limit seems entirely artificial.
Do you know of any way to bump up that limitation or who I might contactat BEA
about the matter?
I'm aware that stack space and other context specific data must beallocated for
each thread so let's say for the sake of argument that each thread takes10KB
of data. That means I get 100 threads per 1MB and it would take 1GB toget my
100,000 threads. That is not an unusually large amount of data ontoday's desktop
computer. Furthermore, with the advent of 64bit computing on thedesktop, we'll
see machines supporting much more than 4GB.
Staffan Larsen <[email protected]> wrote:
First: which version of JRockit is this with?
With thinthreads the limit is 32767 threads. But you may run into other
limits before that. When you increase the heapsize you "steal" memory
from the system (which would otherwise be used for stacks and other data
structures) and that is why you can run fewer threads with a larger
heap.
>>>
I don't think it is realistic to run 100's of thousands of threads in
one single system.
Regards,
/Staffan
Kevin Healy wrote:
I have an application for which I am interested in obtaining as manysimultaneous
threads as possble (e.g. 10's and possibly 100's of thousands of
threads).
>>>>
More specifically I have developed a simulation language formalismin which the
dynamics of each "entity" moving through a network of queues is
coordinated
>>>
by
a separate thread of execution.
This is not a traditional application where all or even some smallnumber are
intended to run concurrently. A single executive thread is responsiblefor alternately
activating and deactivating individual threads to reflect the timeordered sequencing
of events corresponding to each entity's movement through the systemof queues.
As a result, only a single thread is executing at one time.
Using a separate thread for each entity off-loads the task of managingeach's
execution context to the JVM. The resource contention issues thatarise in a
standard multi-threaded application don't apply here.
For "large" systems though (ones populated by many entities
simultaneously)
>>>
I
need many threads.
I'm using JRockit's thin thread model on a Windows XP machine and am"only" able
to get approximately 25000 threads at which point the JVM hangs withno diagnostic.
I say "only" because at that point there seems to be plenty of heapspace left
as well as Page File space left in the XP's Virtual Memory system.
I'm using the following JVM command line:
java -Xthinthreads -Xss32K -Xms256M -Xmx256M -Xallocationtype:global
Surprisingly, by altering the heap size upward from 256MB to 512MBacutally causes
the VM to hang with fewer threads (only 20000 or so)
Using allicationtype:global and altering the stack size of the threadsseems to
have little effect on the maximum number attainable.
It seems the maximum number of threads attaible should be a functionof the size
of the heap space, and the amount of physical and virtual memory limitson the
system.
My empirical evidence, however, seems to indicate there is some
internal
>>>
VM limit.
Can someone explain for me the implementation of the thin thread modeland its
limitations w.r.t. the number of threads it can support?
Thanks in advance for you help.

Similar Messages

  • Maximum number of threads that can be spawned

    Hi
    What is the maximum number of threads that can be spawned from a 64-bit jvm with jdk 1.5? The application runs on
    SunOS 5.10 Generic_118833-24 sun4u sparc SUNW,Sun-Fire-480R
    Thanks

    Somewhere between about 10 and several hundred billion.
    A specific answer can be easily determined by you by actually writing a very small apps that spawns them and counts them.
    You might note that modern OSes limit the number of threads per app. In most or perhaps all unix variants you can change that limit. You can't increase that limit in java.
    Running the maximum number is very unlikely to be good idea however. Requiring that would suggest that the design is broken.

  • Maximum number of threads in a process

    Hello,
    we are currently running on Solaris 9 an application compiled
    with C++ compiler SunStudio 8.
    Our application crash after running 2990 concurrent threads with the system
    error
    ENOMEM (Not enough space).
    In the same time the real memory free was around 8 Gb.
    So what kind of resource was missing ?
    Is there any limit of concurrent threads inside a process ?
    Thanks for any tips.
    Yaakov Berkovitch
    [email protected]

    Hello,
    we are currently running on Solaris 9 anapplication
    compiled
    with C++ compiler SunStudio 8.
    Our application crash after running 2990concurrent
    threads with the system
    error
    ENOMEM (Not enough space).
    In the same time the real memory free was around 8
    Gb.
    So what kind of resource was missing ?
    Is there any limit of concurrent threads inside a
    process ?It could the memory available to the process. You
    don't say if it's a 32bit or 64bit application. If
    it's 32 bit, it could well be out of memory and/or
    stack.
    A+
    PaulOur application is 32-bit.
    But regarding the memory the server has a big mount of free memory so I cannot understand why the OS failed creating a new thread.
    BTW, the system call that failed was thr_create.
    A+ says that "vous parlez francais !!!!"

  • Maximum number of threads can be created in solari

    Dear All,
    This is Amarnath.E, I'm working on high-end server program. As per my requirement i have to create many threads in my program.
    1.Is there any limitation in solaris on creating the no. of threads?
    2. If so how to increase the no. of threads that can be created?
    3.Whether the No. of Threads can be created can vary based on the system configuration?
    Please
    ThanX in advance
    Amarnath.E

    Hello there,
    I believe the previous answer is given correctly. There is no specific
    kernel limit to be set. You will eventually run out of virtual address space
    (after about ~3000 threads). Out of 4 GB virtual address space, kernel
    base address (ie., F0000000) and beyond is reserved for kernel (except
    for Ultra boxes where you can practically get almost 4GB each for
    kernel and process's virtual address spaces). Thus you have about
    3.75GB Sparc (3.5GB on X86 where the kernel base is E000000). It is
    not recommended to reduce the thread stack size (just be sure your new
    stack size will be able to handle the stack growth it needs per thread)
    but, if you are sure it is safe for your purpose, this can be done as an
    argument to a thread creation. Please see also manpage on thr_create.
    hope this helps.
    hae
    Sun Developer Technical Support

  • Create standby maximum number of logfiles for each thread

    The oracle doc states this equation for appropriate number of standby redo log file groups
    (maximum number of logfiles for each thread +1) * maximum number of threads
    How do you get the maximum number of logfiles for each thread and the max thread?
    Thanks!

    If you are running RAC you can, in theory, be running with a diferent count
    of Online Redo Logs in each thread (instance).
    However, normally, you would have the same number of Redo Logs in each
    thread.
    The theoretical max is prescribed at the CREATE DATABASE and can be
    changed with a CREATE CONTROLFILE. If you do an
    ALTER DATABASE BACKUP CONTROLFILE TO TRACE
    the sql script in the tracefile shows the maximum number of logs and members.

  • Maximum number of logfiles for each thread

    Hi all,
    When I configure a Standby Redo Log, to determine the appropriate number of standby redo log file groups, I should use the following formula:
    appropriate number of standby redo log file groups: (maximum number of logfiles for each thread + 1) * maximum number of threads
    My question is: how can I determine the maximum number of logfiles for each thread ? Is it the online redo log file per group? or total of redo log files in all groups?
    SQL> ed
    Wrote file afiedt.buf
      1* select group#, thread#, sequence#, members from v$log
    SQL> /
        GROUP#    THREAD#  SEQUENCE#    MEMBERS
             1          1         40          1
             2          1         38          1
             3          1         39          1

    user8994263 wrote:
    Hi,
    If you have 5 redo log groups on primary, do you suggest to create 6 standby redo log groups on standby?
    If yes, why ?
    -KalidasYou did two mistakes
    1) Responded to old question Posted: Jun 1, 2010 8:52 PM
    2) Its not your question & asking into others threads.
    -- Please lock this thread

  • Max number of threads in a jvm

    Is there any constraint for the maximum number of threads that we can
    create in a particular JVM

    Why do you have to worry about that? I don't see a reason to create lots and lots of threads. The OS will usually spend most of the time doing context switches if you create more than a couple of thousand threads.
    Kaj

  • Max Number of threads per Process in Solaris 8

    I'm running into qpplication which crashes with a segfault when the LWP for that process hits about 255, i'm trying to find the maximum number of threads per process using sysconf and its returning -1
    #include <unistd.h>
    int
    main(void)
    printf("%ld\n",sysconf(_SC_THREAD_THREADS_MAX));
    return 0;
    I'm using gcc 3.3.2
    If anyone can tell me the maximum number of threads per process I would really appreicate it.
    Also the maximum number of open files per process.
    Thanks in advance
    - Rodrick Brown
    - DoITT

    Please make sure that you build a
    multithreaded program first (check with ldd).
    If anyone can tell me the maximum number of threads per process I would
    really appreicate it.
    Also the maximum number of open files per process. It depends on the architecture (x86/SPARC), OS version,
    64 or 32-bit, /etc/system, shell limitations (/usr/bin/ulimit) ...
    Search for "rlim_fd_max / rlim_fd_cur" on docs.sun.com too.
    HTH,
    -vladimir

  • Limiting the number of threads that are created

    I am trying to write a web crawler as a way of learning about multi-threading and I have hit a stumbling block (probably my design). The way the application I have started works is that I provide a single URL, which is passed to a thread and that thread then parses the web page building a list of links (If the links are not already held in a 'visited' list then they are saved in a list in the Runnable object that is parsing the html page).
    When the page has been parsed the list of links are then passed to a method in a Utilities class that creates a new group of threads, 1 for each link and each of these threads then does the same thing. The problem I have is that as more and more links are captured more and more threads are created eventually I either get a out of memory exception or I get an operating system 'cannot create native thread' message. I am not sure if the threads are staying in memory after they have done their tasks, I am not sure why I am running out of memory so quickly.
    What I would like to try and do is to set a limit for the maximum number of threads created and then only create new threads if the limit is not breached. If someone could point me in the right direction that would be good, I have googled around but cant find an example of what I want to do.
    Thanks

    Thanks for that, that has given me a lot to read up on and I can already see where I went wrong.... I think implementing a thread pool and also a work queue is probably the way I will go from now on.

  • Number of Threads Question

    Hi,
    I'm working on a pretty big program and i need a lot of threads to make it run well (it's an audio player and, of course, i don't need people to wait when, for example, they save a playlist). So, i put some of these tasks on different threads, plus others that i didn't need for making the program run faster, but they are there just to make the program run. Now i have at least 4 threads running at the same time and, in some cases, there are even 6 or 7. Is it too much? It's my first big program (it's just for fun but i still want it to run well) and i didn't need so many threads before. What's the maximum number of threads you'd recommend me to have?
    Thanks.

    Anakin1989 wrote:
    Hi,
    I'm working on a pretty big program and i need a lot of threads to make it run well (it's an audio player and, of course, i don't need people to wait when, for example, they save a playlist). So, i put some of these tasks on different threads, plus others that i didn't need for making the program run faster, but they are there just to make the program run. Now i have at least 4 threads running at the same time and, in some cases, there are even 6 or 7. Is it too much? It's my first big program (it's just for fun but i still want it to run well) and i didn't need so many threads before. What's the maximum number of threads you'd recommend me to have?
    Thanks.Are you experiencing any problems with the number of Threads you have? If not, stop worrying. On the other hand, are you sure you need all of them? There are alternatives to Threading, such as SwingWorker and Timer that might be able to help you out.
    One thing you better make sure of is that you're not doing any Swing work off of the EDT, or doing things like sleeping or time-consuming work on the EDT.

  • Is there any way to limit the number of Threads running in Application(JVM)

    Hello all,
    is there any way to limit the number of Threads running in Application(JVM)?
    how to ensure that only 100 Threads are running in an Application?
    Thanks
    Mohamed Javeed

    You should definitely use a thread pool for this. You can specify maximum number of threads that can be run. Be note that the thread pool will only limit the number of threads that are submitted to it. So donot call "Thread"s start() method to start thread on your own. Submit it to the pool. To know more, study about executor service and thread pool creation. Actually it will not be more than 20 line code for a class and you might need maximum of 2 such classes, one for threadPool and other one for rejection handler (if you want).
    Just choose the queue used carefully, you just have to pass it as a parameter to the pool.
    You should use "Bounded" queue for limiting threads, but also be careful in using queues like SynchronizedQueue as the queue will execute immediately the threads submitted to it if maximum number of threads have not been running. Otherwise it will reject it and you should use rejection handler. So if your pool has a synchronized queue of size 100, if you submit 101th thread, it will be rejected and is not executed.
    If you want some kind of waiting mechanism, use something like LinkedBlockingQueue. What this will do is even if you want 100 threads, you can specify the queue's size to be 1000, so that you can submit 1000 threads, only 100 will run at a time and the remaining will wait in the queue. They will be executed when each thread already executing will complete. Rejection occurs only when the queue oveflows.

  • Java.lang.IllegalStateException: Exceeded maximum number of waiting threads

    Hi all,
    I use coherence3.3.1,coherence work as hibernate L2 cache and meet following problem,could you help me check the problem?thanks.
    java.lang.IllegalStateException: Exceeded maximum number of waiting threads (Status=2)
         at com.tangosol.net.cache.OverflowMap$Status.waitForAvailable(OverflowMap.java:4029)
         at com.tangosol.net.cache.OverflowMap.prepareStatus(OverflowMap.java:2152)
         at com.tangosol.net.cache.OverflowMap.beginKeyProcess(OverflowMap.java:1873)
         at com.tangosol.net.cache.OverflowMap.getInternal(OverflowMap.java:580)
         at com.tangosol.net.cache.OverflowMap.get(OverflowMap.java:330)
         at com.tangosol.coherence.component.util.CacheHandler.getLease(CacheHandler.CDB:3)
         at com.tangosol.coherence.component.util.CacheHandler.getCachedResource(CacheHandler.CDB:10)
         at com.tangosol.coherence.component.util.CacheHandler.get(CacheHandler.CDB:1)
         at com.tangosol.coherence.component.util.SafeNamedCache.get(SafeNamedCache.CDB:1)
         at com.tangosol.coherence.hibernate.CoherenceCache.get(CoherenceCache.java:65)
         at org.hibernate.cache.StandardQueryCache.get(StandardQueryCache.java:105)
         at org.hibernate.loader.Loader.getResultFromQueryCache(Loader.java:2152)
         at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2117)
         at org.hibernate.loader.Loader.list(Loader.java:2087)
         at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
         at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
         at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
         at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:150)
         at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:804)
    j

    Hi,
    Can you please provide the relevant coherence config files?
    thanks,
    -Rob

  • [Project Server 2010] Maximum Number of Job processor Threads in the queue settings

    Hello,
    I have a farm with SharePoint 2010 and Project Server 2010 installed. The farm contains:
    2 web front end servers
    3 application servers
    Each servers has 4 processors
    The SQL databases are installed on our database servers.
    The Microsoft Project Server Queue Service 2010 is started on the 2 web front end servers and on 1 applicative server.
    We have two instances of PWA are installed on this farm.
    I have calculated that the number of availabe processors we could have on this farm is : 4 processors X 3 application servers (the ones where the project queue is started) = 12. Is that correct? I'm not sure of the definition of the applicaton
    server that is used in
    this article )
    If I set the Maximum Number of Job Processor Threads (in the queue setting) to 2 per queue and per instance. We could have 2 Job processor X 3 application servers X 2 pwa instance = 12 threads to operate at the same time, is it correct?
    If yes, do you think this is a too high number of threads?
    Thanks for your help
    Aline

    Hi Aline,
    These settings are for fine tuning the servers, and are only one of many performance parameters.  If you notice the response from the server is slow, regarding Queues, then I would think about amending these upwards, but also with a careful eye on processor
    utilisation.  If you up the thread count and the system isn't any more performant, then I would look elsewhere for perf improvements.  Before you do anything of course, baseline the performance of the system.
    Ben Howard [MVP] | web |
    blog |
    book | P2O

  • Maximum number of running JRun threads - where to set?

    Hi,
    I have been looking to increase the maximum number of JRun threads on CF8 Standard on Linux. However, changing jrun.xml (<attribute name="activeHandlerThreads">100</attribute> in the JRunProxyService section) did nothing after restarting CF and Apache and I have not been able to find it anywhere in the Administrator. Anybody have any ideas or have I missed something really obvious?
    CF administrator does not list the value anywhere apart from the settings summary.
    Thanks
    Meint

    Ok, I changed the WebService setting and it now shows the new value in CF Administrator. However, it does have me wondering if this is possibly a bug in CF Administrator? Does it always show the JRun threads against the internal web server, even if you are using an external web server like Apache? Reason for asking is that the relevant sections against the JrunProxyService section clearly state that this is for an external web server and the WebService section states it is for the internal web swerver? Bit confused now but have got it working as expected. Is there another way of finding out the JRun thread value other than the CF Administrator?
    Regards
    Meint

  • Illustrator won't run: "unable to set maximum number of files to be opened"

    I have an intel macbook pro (core duo with 2GB ram) and a copy of purchased adobe creative suite 2. Other applications in the suite like photoshop, acrobat, etc can run on my mac without any problem. But when I try to run illustrator, it just shows an error message "Unable to set maximum number of files to be opened" and quits. I also installed a trial version of illustrator cs3 and got the same problem. Can anyone help? Thanks.
    CC

    Hi, I realize this is an old thread but it was unanswered and the issue has come up again in a newer thread:
    http://forums.adobe.com/message/2534652
    If the original poster sees this, can you reply tin the new thread and let us know if you were ever to solve this problem?
    Thanks!

Maybe you are looking for