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.

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.

  • Thread Pool with Min,Max. and other thread parameters

    hello,
    I found an Implementation of ThreadPool in the java.sun.com,but it didn't have the minimum,maximum no. of threads implemented in the code.
    Could you help me find out an implementation of Thread Pool,that keeps track of minimum no. of threads,max. no. of threads in the pool,the increment size of threads,number of idle threads,idle time allowable for a thread,etc...
    I also need to know if it is possible to have >5000 threads in a ThreadPool,beacuse I get OutofMemoryError,when I used a ThreadPool( which didn't have any of the above-mentioned parameters!)
    Thanks!!!

    Having greater then 5000 threads is a sign of a problem with your design. Threads are relativly costly
    beasties. The idea of using a pool for your threads is that you won't need to use 5000 threads
    simultaniously. Most OS's will have problems trying to create this many threads per process (unless you
    tune the OS itself (which is normally not too difficult))
    matfud

  • 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

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

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

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

  • What's the semantic of "max user processes" (ulimit)

    Hello everyone,
    I don't understand the behaviour of ulimit, have a look at this shell dump:
    $ ps hax | wc -l
    120
    $ ps h -u myUsername | wc -l
    35
    $ ulimit -Su 78
    $ ps h -u myUsername | wc -l
    bash: fork: retry: No child processes
    bash: fork: retry: No child processes
    bash: fork: retry: No child processes
    bash: fork: retry: No child processes
    bash: fork: Resource temporarily unavailable
    $ ulimit -Su 80
    $ ps h -u myUsername | wc -l
    35
    $
    If I am currently running 35 processes, one would assume that >35 more should be sufficient to start two more processes - but obviously it isn't.
    In this case, I needed at least "ulimit -Su 80" to start ps and wc.
    If I set the "max user processes" limit to 79, the first four error messages change from "bash: fork: retry: No child processes" to "bash: fork: retry: Resource temporarily unavailable"
    Can somebody explain this bevahiour to me, please? Why am I not allowed to create new processes, although the limits should be sufficient?

    Apologies for the necro-bump but I hope this will help others.
    ulimit -u does not give you the max number of processes rather it displays the max number of threads.  To list the number of threads a user is currently using:
    ps -L -u myusername | wc -l
    The output from the above two commands can now be compared and allow you to set the appropriate ulimit.

  • Threads running in web container

    How to get current web container active threads count,and how to get the max web container thread count ,in weblogic

    Hello Slava,
    The output you see when running to web from Reports Builder is controlled by the web source of your report. Please take a look at your web source and confirm whether that the reports JSP tags are indeed present to fetch the data and format the web output.
    Also, note that if you want to deploy your report using its web layout, you would need to save it as a JSP, as only JSPs can be deployed directly over the web.
    RDF files can be run over the web only using rwservlet, and doing so will cause the output to be formatted using the report's paper layout instead of it's web layout.
    Thanks,
    The Oracle Reports Team.

  • Problem to increaase max open files to more than 1024

    Hello,
    I tried to increase the max open files to more than 1024 in the following way
    $ sudo nano /etc/security/limits.conf
    mysql hard nofile 8192
    mysql soft nofile 1200
    However, after reboot I am still not able to start MariaDB:
    $ sudo systemctl start mysqld
    Job for mysqld.service failed. See 'systemctl status mysqld.service' and 'journalctl -xn' for details.
    $ sudo systemctl status mysqld
    ● mysqld.service - MariaDB database server
    Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
    Active: activating (start-post) since Tue 2014-09-02 13:08:20 EST; 53s ago
    Main PID: 6504 (mysqld); : 6505 (mysqld-post)
    CGroup: /system.slice/mysqld.service
    ├─6504 /usr/bin/mysqld --pid-file=/run/mysqld/mysqld.pid
    └─control
    ├─6505 /bin/sh /usr/bin/mysqld-post
    └─6953 sleep 1
    Sep 02 13:08:20 acpfg mysqld[6504]: 140902 13:08:20 [Warning] Could not increase number of max_open_files to more than 1024 (request: 4607)
    I am using the following /etc/mysql/my.cnf
    [mysql]
    # CLIENT #
    port = 3306
    socket = /home/u/tmp/mysql/mysql.sock
    [mysqld]
    # GENERAL #
    user = mysql
    default-storage-engine = InnoDB
    socket = /home/u/tmp/mysql/mysql.sock
    pid-file = /home/u/tmp/mysql/mysql.pid
    # MyISAM #
    key-buffer-size = 32M
    myisam-recover = FORCE,BACKUP
    # SAFETY #
    max-allowed-packet = 16M
    max-connect-errors = 1000000
    skip-name-resolve
    sql-mode = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY
    sysdate-is-now = 1
    innodb = FORCE
    innodb-strict-mode = 1
    # DATA STORAGE #
    datadir = /home/u/tmp/mysql/
    # BINARY LOGGING #
    log-bin = /home/u/tmp/mysql/mysql-bin
    expire-logs-days = 14
    sync-binlog = 1
    # CACHES AND LIMITS #
    tmp-table-size = 32M
    max-heap-table-size = 32M
    query-cache-type = 0
    query-cache-size = 0
    max-connections = 500
    thread-cache-size = 50
    open-files-limit = 65535
    table-definition-cache = 1024
    table-open-cache = 2048
    # INNODB #
    innodb-flush-method = O_DIRECT
    innodb-log-files-in-group = 2
    innodb-log-file-size = 128M
    innodb-flush-log-at-trx-commit = 1
    innodb-file-per-table = 1
    innodb-buffer-pool-size = 2G
    # LOGGING #
    log-error = /home/u/tmp/mysql/mysql-error.log
    log-queries-not-using-indexes = 1
    slow-query-log = 1
    slow-query-log-file = /home/u/tmp/mysql/mysql-slow.log
    How is it possible to increase the number?
    Thank you in advance.

    Change/add in the my.ini file, under [mysqld]:
    max_allowed_packet=2048M
    Reference:
    * http://dev.mysql.com/doc/refman/5.5/en/ … wed_packet

  • How to limit threads in a Java QuickSort algorithm.

    With the following piece of code, I quickly run into OutOfMemory exceptions, since the code starts creating Threads exponentially. However, after waiting for a long time (for all the exception texts to print out, obviously making it slower than running it with one thread only), the program eventually ends with the correct result. Is there a way to run the code as is, but making sure that no more that x threads are running at a time?
    things I have tried:
    - sleeping the current thread - makes it slower than one-thread.
    - looping blank while Thread.activeCount() > x - doesnt work at all
    - suspending resuming threads based on the activeCount - doesnt work too
    Code:
    import java.util.*;
    import java.io.*;
    public class ThreadedSort extends Thread{
    private ArrayList<Integer> _list;
         public ThreadedSort()
              _list = new ArrayList<Integer>();
         public ThreadedSort(ArrayList<Integer> List)
              _list = List;
         public void run()
              threadQuickSort();
    public void threadQuickSort()
              try{
    if (_list.size() < 2)
    return;
    Integer pivot = new Integer(_list.get(_list.size()-1));
              ArrayList<Integer> left = new ArrayList<Integer>();
              ArrayList<Integer> right = new ArrayList<Integer>();
    //ListIterator iter = arr.listIterator();
              // *** optimize here
    for (int i = 0; i < _list.size()-1; i++) {
                   Integer next = (Integer)_list.get(i);
                   if (next <= pivot)
                        left.add(next);
                   else
                        right.add(next);
              ThreadedSort LeftThread = new ThreadedSort(left);
              ThreadedSort RightThread = new ThreadedSort(right);
    //          System.out.println(Thread.currentThread().getName()+" --> "+Thread.activeCount());
    //          Thread.sleep(4000);
              LeftThread.start();
              RightThread.start();
    //          System.out.println(Thread.currentThread().getName()+" --> "+Thread.activeCount());
              LeftThread.join();
              RightThread.join();
              _list.clear();
              list.addAll(LeftThread.list);
              _list.add(pivot);
              list.addAll(RightThread.list);
              }catch (InterruptedException ie) { ie.printStackTrace(); }
              return;
    public static void main(String[] args) { ///////////////////////////////////////////
              Random rand = new Random();
              ArrayList arr1 = new ArrayList();
              long before_threadedQuickSort, after_threadedQuickSort;
              try{
              FileWriter fout = new FileWriter("out.txt");
              BufferedWriter bw = new BufferedWriter(fout);
              before_populate = System.currentTimeMillis();
              for (int i = 0; i< 2000; i++){//***
                   arr1.add(rand.nextInt(2000000));
              after_populate = System.currentTimeMillis();
              ThreadedSort sorter3 = new ThreadedSort(new ArrayList(arr1));
              before_threadedQuickSort = System.currentTimeMillis();
              sorter3.start();
              sorter3.join();
              after_threadedQuickSort = System.currentTimeMillis();
              bw.write("time for threadedQuickSort: " + (after_threadedQuickSort - before_threadedQuickSort)); bw.newLine();
              bw.newLine();
              arr1.clear();
              bw.close();
              }catch (Exception IOException){};
              System.out.printf("\n\n");
    } //end of main
    } //end of class

    So you dont have to go thru the code:
    Quicksort:
    with one thread only I start the sorting by choosing a pivot from the initial list and then generating a left list (all values less then pivot) and a right list (all values greater then pivot).
    then i recursively call quicksort with the left and right lists.
    with one thread that works fine.
    threadedQuickSort:
    each thread object has a variable _list that keeps its list.
    from the initial thread, i do generate again two lists (left and right) but then i construct two threadable objects with those lists and start them, creating for each list a new thread.
    so each thread will create two new threads.
    for a initial list with up to 2000 rows, that yields to the correct result although much slower than the one-threaded version. maximum number of threads ever used was around 500~600.
    for a list with 20000 rows, my machine chokes at around 2600 threads. (OutOfMemory exception)
    My Processor is a 8 core (each core can run up to two threads) giving me a total of 16 actual threads i can work with.
    So the question is how to limit the threads that are created to 16. There is no method in the Thread class where you can specify the max number of threads in a threadgroup.
    @ jverd:
    I looked at ThreadPoolExecutor, but it looks kinda complicated. I see that the idea is creating a queue of jobs to be executed (which would be the different sublists (left and right lists), and then using the specified number of threads to work with the queued jobs, but im failing to understand how it works. Can you point to a simple example somewhere showing how to declare a ThreadPoolExecutor object and work with it. thanks

  • Query Regarding Execute Thread Count

    Hi,
    My understanding of Execute Thread Count is the threads which are assigned to service
    requests coming to Weblogic Server.
    In our current architecture a request for generating report is directed to EJB method
    which makes a call to another Server (Report Server for executing reports), the report
    Server in turn calls the EJB residing on Weblogic Server for getting the data.
    So, is my assumption correct that with our current architecture we are limited to
    concurrency of Execute Thread Count -1. (Every request for report will consume 2
    Excute threads, and others will have to wait till the first request gets completed
    and 2 threads are freed).
    I also read from the postings that Weblogic takes some of the threads, so it actually
    will be limited to (Execute thread count - Weblogic Held- 1).
    Please corect me if I am wrong.
    Thanks and Regards
    Rashmi

    Hi,
    Thanks very much for the suggestion. I tried, and it is using 2 Execute Threads.
    Thanks
    Rashmi
    "Dave Martin" <[email protected]> wrote:
    >
    Rashmi:
    If you are interested in answering the question rigorously, why not just
    throw a
    fake exception along both the report generation path and the runReport method
    of
    the ReportServer, then record their stack traces to a file for comparison?
    From the sounds of it, your app wants to make the actual report generation
    asynchronous
    from the post of the reporting request. If they're really asynchronous,
    then your
    ReportServer must have some kind of blocking queue that will "wake up" when
    it has
    work to be done. Depending on how you implemented this, your runReport
    method may
    not be running a WebLogic execute thread at all.
    Seems to me that you should be thinking of this as consuming one execute
    thread regardless.
    Even if the two pieces of work are asynchronous, the first thread finished
    its work
    at the point that it posts to the second thread (at least, per your description).
    So at any one time, at max one execute thread is being consumed per request.
    But capture the stack traces and have a look for yourself.
    Dave Martin
    "Rashmi S" <[email protected]> wrote:
    Hi,
    Thanks for your reply.The reason why I say 2 threads will be consumed is
    as follows
    1. First execute thread will be used for the request to Weblogic Server
    to run the
    report originating from a client.
    2. Now, within the ReportServices EJB there is a call to Report Serverto
    run the
    report. The running of report is done on the Report Server which is ona
    separate
    m/c. Within the runReport method of the Report Server ,the data is fetched
    for the
    report by making a context look-up of another session EJB which fetches
    the data.
    So, the second Execute thread will be consumed for executing the EJB that
    fetches
    the data.
    Am I correct?
    Thanks and Regards
    Rashmi
    "Cameron Purdy" <[email protected]> wrote:
    Incoming requests (from outside the server) use one thread for the duration
    of their processing. Previous to their processing they are queued until
    a
    thread is available. So you would use one thead per concurrent request,
    not
    two. Otherwise, it sounds right.
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    Clustering Weblogic? You're either using Coherence, or you should be!
    Download a Tangosol Coherence eval today at http://www.tangosol.com/
    "Rashmi S" <[email protected]> wrote in message
    news:[email protected]...
    Hi,
    My understanding of Execute Thread Count is the threads which are assignedto service
    requests coming to Weblogic Server.
    In our current architecture a request for generating report is directedto EJB method
    which makes a call to another Server (Report Server for executingreports), the report
    Server in turn calls the EJB residing on Weblogic Server for getting
    the
    data.
    So, is my assumption correct that with our current architecture we arelimited to
    concurrency of Execute Thread Count -1. (Every request for report willconsume 2
    Excute threads, and others will have to wait till the first request
    gets
    completed
    and 2 threads are freed).
    I also read from the postings that Weblogic takes some of the threads,so
    it actually
    will be limited to (Execute thread count - Weblogic Held- 1).
    Please corect me if I am wrong.
    Thanks and Regards
    Rashmi

Maybe you are looking for

  • ITunes Movie Download keeps stopping at 1.64GB

    Hiya, I recently bought the Avengers off iTunes [HD, trying 1080p] but everytime the download gets to around 1.64GB, the timer vanishes and the progress bar stops going up indefinatly, though it says it's still downloading. The iTunes extra part of t

  • Print the Report Name

    I need to print report's name as a part of header information. What I have to do?

  • HP's Low Grade Hinges and Warranty Issue.

    Hello,   HP Area Heads,  Envy Notebook Division Heads,  Support Division Heads  and CEO. I regret to say that perhaps buying an HP Envy laptop worth Rs, 1,15,000/-  will turn out to be my big mistake. I never thought that HP would use a LOW Grade mat

  • Login Page - Change How Users are Authenticated

    Hi all, I have done a function in a package: function checkPassword( p_username in varchar2, p_password in varchar2 ) return boolean is db_password number; begin select password into db_password from people where username = p_username; if db_password

  • Evince print to network printer

    I'm having a hard time with this and nothing's coming up. I have a printer I'm successfully connected to via CUPS, I can print fine in OpenOffice. However, evince won't print. The "print" button is grayed out. I -need- to print PDFs and right now lit