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

Similar Messages

  • "max number of thread"

    We are running a java web app on a Ubuntu Oracle WebLogic server version 10.3.3.
    The java web app performs long polls with open tcp socket to keep the client connection open. The clients are long polling the WebLogic at 30 seconds.
    Currently we are not able to maintain stability for greater than 24 hours with approximately 200 simultaneous sessions on WebLogic server. Session to me is active client/server tcp connection. We have re-written our application to use continuations, but we are seeing ConcurrentModificationException errors in performance testing.
    Is there any setting in WebLogic for “max number of thread” that can handle?
    Edited by: user9316392 on Jul 8, 2010 11:07 AM

    First, WebLogic since 9.0 has a self-tuning thread pool where WLS will automatically grow and shrink the number of threads based on some internal algorithms. I'm not aware of a hard limit so theoretically there is no max thread count as long as the JVM has memory and WLS thinks more threads will help. You can read up on it here:
    http://www.oracle.com/technology/pub/articles/dev2arch/2006/01/workload-management.html
    Practically, I wouldn't expect more than several hundred threads to be helpful.
    As for your situation, how does WLS become unstable? Out of memory, out of file descriptors, errors on new requests, etc. I think you're going to have to use some JVM tools to see what happens to your JVM over time. Is there a memory leak somewhere, is it non-heap memory, etc. JRockit Mission Control is helpful if running on JRockit. If you're on Sun Hotspot, them presumably you can use some of the Hotspot tools. You'll want to compare the state of the JVM towards the beginning of your load test, but after a slight warm-up period with a snapshot after the load test has been running for a long period of time.

  • Max number of Thread allowed

    I am writing a multi threading program.
    is there any limit on max number of thread allowed?
    if yes, how to check the limit?

    For the language: no. It depends on your memory (every Thread has its own stack, etc.).
    Kind regards,
      Levi

  • Max number of threads in Java?

    Hi,
    I am running into a bug now that I am testing my working code. Basically, my program creates a bunch of objects that talk to each other. Each object is a thread, and at a given time (there is a one object that keeps track of time) a thread may choose to message another thread. My problem is that when I create more objects, my code doesn't run to completion. For example, when I have 10 objects talking to each other, things work fine. But if I have 15, they all run for a little bit, then the program seems to just hang and not do anything.
    Is there a limit as to how many threads I can have? If I was out of memory or something, I'd get an exception, right? But I don't get anything - it just seems like things "freeze up".

    15 threads? shouldn't be a problem.
    I think th emax threads allows runs in thousands..if not ten of thousands.Java process threads itself use about 600 or more threads. howevr, it could also be the underlying system restr8iction on the number of threads allow per process????
    for you case: it's highly likely you run into the max # of threads.
    I can only think of two reasons for your application to freeze:
    1. Deadlock
    if you have an object that is synchronized..than you might have run into a deadlock (race-condition)
    for example:
    Object A has the key for Object X , and waiting for Object Z
    Object B has the key for Object Z, and waiting for Object X
    as you can see..they will never gives up the lock....so you're in a dead lock.
    2. Low memory resource. (Memory - Paging and Thrashing)
    Each of your thread is using up the resouces (memory) and processing power.
    When you reach the max or near max and needs to create more memory..the garbage collector kick in
    and try to reclaim some unused memory. This can slow down your application dramatically if the garbage
    collector is invoke often.
    Also..paging is performed when you reach max memory..the operating system keep on paging your memory (usually happens when there's a lot of threads and not enough memory. If this happen..than it
    can cause your program to becomes freeze like....remeber..each thread is given a small amount of time to
    perform a task..if the time it takes to load a page for a thread is almost equals to context switch time..than
    no work is really done..and your program "freeze"
    solution..redesign you app to prevent thrashing.
    it is likely paging is the culprit..but i would not dismiss deadlock issues.

  • 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

  • Max number of sockets provided by JVM

    Hi,
    I am currently working on a program that creates a vast number of stream-oriented sockets and I encountered some problems that made me wonder whether there is a maximum number of sockets available.
    I searched the forum for a hint but only found vague answers. What I am particularly interested in is a statement whether there is a maximum number of sockets that can be managed by the virtual machine regardless of the hardware provided or the operating system in use.
    Thanks in advance.

    If I were to write Java, I would not impose an
    arbitrary limit but would rely upon the operating
    system and thus "inherit" the limit from there.Correct. It's the OS that specifies the limitations in this case.

  • How to find out the number of threads created under java vm at runtime

    our application seems to have hit the max number of threads that can be created under vm and the vm will just hang after that. that behavior seems to be consistent from an article that I read earlier.
    I wonder any way that java app can find out the number of threads currently created under vm?
    thanks in advance!

    If you are not starting an extra thread group you can use the Thread.activeCount method. But this willnot return all the threads, as there are some jvm threads, i.e. garbage collector. Also if you are running on a Unix type operating system then you can send a signal to the jvm to give you a thread dump, i think the signal is sighup.
    If the application is hanging i would of thought that you have a deadlock situation rather then the JVM not being able to create new threads, roughly how many threads should be running ??

  • Tuning the good number of thread with Work Manager?

    Hi,
    I search some best practice or experience return on the max thread number on a weblogic managed server
    I try to explain: with WLS 8.1 and execute queue it was hard to tune the good number of thread but possible (with some processor and for an application we find that after 30 concurrent thread, there's lower performance because of switch on processeur, for others it was 45 for example)
    Now i can see sometimes more than 500 thread on one JVM and it seem to be very much for me!!
    we face some problem of response time in PRODUCTION, i can see sometimes more than 100 Stuck thread on a resource, so i think it's the reason of bad response time. But with Work Manager, it increase the number of thread to accept others request and the CPU stay at acceptable level (less than 50%) because the stuckthread are do nothing (waiting for resource)
    So i don't understand the good tuning to apply since WorkManager...ok it isn't normal to have a lot of stuck thread but if there's no matter about the max number of thread, is it useful to stop and restart managed server?
    do you think we can have have bad performance if there's a lot of thread?
    thank you for your experience return. If you have no idea just tell me how much thread you can see on your managed server in Production.

    up, up...
    we have always the same probleme in production: 50 stuck thread on each JVM since 15 days....
    the manages serveurs are in warning but don't seem to be disturb cause the work manager add more threads dynamicaly.
    Anyone have idea if this situation is a probleme for response time on other request ?
    reboot managed solve this situation but i would like to understand the consequence of this situation.
    thanks a lot for your experience.

  • Max no of threads

    Is there such a thing as a max number of threads in a midp j2me application. My application, which makes extensive use of threads is suffering from hanging, where is shouldn't. How do I remedy this?
    Thanks.
    Pier.

    I am porting a agent programming api to the pda platform. Each agent has it's own communications, class loading and other threads. These threads have to be alive so that they are ready to execute any time this particular agent receives messages from another agent.
    So my problem does not have anything to do with the number of threads?
    Does it have anything to do with how j2me handles threads? My program runs with no problems at all on the wireless toolkit emulator. BUt on the iPAQ, sometimes it hangs near the beginning where several threads are being initiated. If it gets past that stage, there are no problems though.
    Any guesses to help me? :)
    Pier.

  • 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.

  • Max no# of threads in a single session

    Hi all,
    I have a scenario wherein I have connected to SAP from JAVA using XBP interfaces.
    I want to call BAPI_JOB_DEFINITION_GET concurrently in a single session using sync threads. The problem what I am facing here is, I am able to handle 15 to 20 connections but for high volumes of threads(50) the JVM is crashing.
    I guess there is some limit set from SAP end.
    Could anybody provide any suggestions or advice about, the maximum number of connections and how can I set the parameter to modify the limit.
    Thanx in advance
    Milind.

    This topic should be posted in the Java Programming section, not the xMII section...

  • Max number of chars in process message MSEL?

    Hi, what is the max number of characteristics can be used in process message category's MSEL table? Right now, I am using more than 99 characteristics and I get a short dump DYNPRO_FIELD_CONVERSION. Is it really limited to 99 characteristics and if it is true, is there an OSS note to change it to allow more than 99?
    Thanks and points available

    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

  • Stack size for native thread attaching to JVM

    All:
    I have a native thread (see below, FailoverCallbackThread) that attaches to the JVM and does a Java call through JNI. The stack size for the native thread is 256KB.
    at psiUserStackBangNow+112()@0x20000000007a96d0
    at psiGuessUserStackBounds+320()@0x20000000007a8940
    at psiGuessStackBounds+48()@0x20000000007a8f60
    at psiGetPlatformStackInfo+336()@0x20000000007a9110
    at psiGetStackInfo+160()@0x20000000007a8b40
    at psSetupStackInfo+48()@0x20000000007a5e00
    at vmtiAttachToVMThread+208()@0x20000000007c88b0
    at tsAttachCurrentThread+896()@0x20000000007ca500
    at attachThread+304()@0x2000000000751940
    at genericACFConnectionCallback+400(JdbcOdbc.c:4624)@0x104b1bc10
    at FailoverCallbackThread+512(vocctx.cpp:688)@0x104b8ddc0
    at start_thread+352()@0x20000000001457f0
    at __clone2+208()@0x200000000030b9f0
    This causes stack overflow in Oracle JRockit JVM. (It does not cause overflow with Oracle Sun JDK.) Is there a recommended stack size for this use case for JRockit? Is there a way to compute it roughly?
    Platform Itanium 64 (linux)]
    java version "1.5.0_06"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
    BEA JRockit(R) (build R26.4.0-63-63688-1.5.0_06-20060626-2259-linux-ia64, )
    mp

    How do I found default heap size, stack size for the
    thread, number of threads per jvm/process supported ?The threads is OS, OS install and jvm version specific. That information is also not useful. If you create the maximum number of threads that your application can create you will run out of memory. Threads require memory. And it is unlikely to run very well either.
    The default heap size and stack size are documented in the javadocs that explain the tools that come with the sun jdk.
    and how the above things will vary for each OS and how
    do I found ? Threads vary by OS, and OS install. The others do not (at least not with the sun jvm.)
    If I get "OutOfMemoryError: Unable to create new native thread" Most of the time it indicates a design problem in your code. At the very lease, you should consider using a thread pool instead.
    I found in one forum, in linux you can create maximum
    of 894 threads. Is it true ?Seems high since in linux each thread is a new process, but it could be.

  • Get Max no of Threads allowed by OS

    Is there a way in java to programatically get the maximum number of threads that are allowed to be created by an operating system?
    Thru my readings on forums, I gather that though there is no such limit for green-type of java threads (I am not sure what green-type means), other regular threads are bound by the max thread limit allowed by the kernel. Is there a way to programmtically get this limit?
    If there is no such API to get this information in Java directly, is there some command that can be invoked using the Runtim.exec() methods depending upon the OS type?
    Thank you

    It depends probably on the OS, the mem size, the number and type of CPUs... in short: Java isn't really supposed to care.
    There is no way, and IMO there also isn't really a need to know.

  • In Oracle 10g, what is the max number of values we can pass to  'IN' Clause

    Hi,
    In my SQL query i have a scenario like, i have to pass the values to 'IN' Clause dynamically from other application. I want to know what is the the max number of values i can pass to 'IN' Clause.
    i have searched in many pages i seeing answers like 'may be 1000' , 'not sure'....
    Could any one tell me the exact limit of IN Clause in 10g.
    Thanks in Advance.
    Chandran

    Hi, Chandran,
    Chandran M wrote:
    In my SQL query i have a scenario like, i have to pass the values to 'IN' Clause dynamically from other application. I want to know what is the the max number of values i can pass to 'IN' Clause.
    i have searched in many pages i seeing answers like 'may be 1000' , 'not sure'....Don't overlook [Dont want to know|http://forums.oracle.com/forums/thread.jspa?messageID=2683385&#2683385]. This may explain why people are reluctant to give a straight answer.
    Could any one tell me the exact limit of IN Clause in 10g.1000 items such as IN (1, 2, 3, ..., 1000)
    No limit on the number of sets: IN ((1), (2), (3), ...) *<=== NOT QUITE!* See below
    No limit in sub-queries: IN (SELECT ...)
    Edited by: Frank Kulash on Jun 3, 2009 9:43 AM
    The limit of 1000 applies to sets of single items: (x) IN ((1), (2), (3), ...)
    There is no limit if the sets contain two or more items: (x, 0) IN ((1,0), (2,0), (3,0), ...)
    Thanks to Michaels for pointing this out.
    Edited by: Frank Kulash on Jun 3, 2009 10:22 AM
    Fixed link

Maybe you are looking for