Thread status in a threadpool

i created one thread pool in java to execute number of tasks parallel. but i want to find out any thread in the thread Pool is hung. how can i find out individual status of each thread in the thread pool. please help me out.

The only way I see to get a Thread out of a ThreadPoolExecutor is to extend it and override the beforeExecute() method. So I guess you'll have to write your own executor that'll limit the time a Thread is allowed to run (or however you define your "hung").

Similar Messages

  • Capture Thread Status Using ExecuteThreads

    I am attempting to capture when threads transition into
    a hogger or stuck state. I get the ExecuteThreads object
    from the MBeanServerConnection object using the ExecuteThreads attribute.
    After I place a JVM into a stuck state, the status of the
    ExecuteThreads object does not reflect that change in status.
    What piece am I missing to correctly capture a stuck thread status?
    connection = connector.getMBeanServerConnection();
    ObjectName executeQueueRT[] = (ObjectName[]) connection.getAttribute(serverRT[a],"ExecuteQueueRuntimes");
    for(int b=0;k<executeQueueRT.length;b++)
    ExecuteThread[] executeThreads=(ExecuteThread[])connection.getAttribute(executeQueueRT, "ExecuteThreads");
    for(int c=0;c<executeThreads.length;c++)
    *hogger = executeThreads[c].isHogger();     // ALWAYS FALSE*
    *stuck = executeThreads[c].isStuck();     // ALWAYS FALSE*

    Your code looks correct, however I think you have not put a thread in your server at a STUCK state.
    To put a thread in a STUCK state you should make the thread to be active for more time than the configured "Stuck Thread Max Time" (default is 600 seconds).
    Go to the Admin console, and select the server you want to monitor for stuck threads. In its configuration tab go to Tuning. There you can configure the Stuck Thread Max Time.
    Then in your application (EJB, WS, jsp) pause a method that you can invoke with Thread.sleep(1000000);
    and then invoke this method.
    If your Stuck Thread Max Time is set for example to 600 seconds and you pause the Thread for 1000 seconds (1000000 ms) you will see a stuck thread after 600 seconds from the moment you invoked this method and for 400 seconds untill the Thread.sleep returns.

  • Showing thread status

    Hi, I need help showing a threads status. I am trying to do an exercise out of a teach yourself book, using threads. I created 3 threads and gave them a priority of 10, 5, and 1. To make sure it is working, I want to start the threads and then stop them in order of max priority to show the lower priority threads running after the higher threads have stopped. Any ideas on how to demonstrate this, and how to get a threads current status (ie sleeping, running, stopped?). Thanks, john.

    public int status()
    Returns the thread's status. If the thread is not suspended the thread's current status is returned. If the thread is suspended, the thread's status before the suspension is returned (or THREAD_STATUS_UNKNOWN if this information is not available. isSuspended() can be used to determine if the thread has been suspended.
    Returns:
    one of THREAD_STATUS_UNKNOWN, THREAD_STATUS_ZOMBIE, THREAD_STATUS_RUNNING, THREAD_STATUS_SLEEPING, THREAD_STATUS_MONITOR, THREAD_STATUS_WAIT, THREAD_STATUS_NOT_STARTED,
    Throws:
    ObjectCollectedException - if this object has been garbage collected

  • Thread status - alive or killed

    In my application, i use threads.
    When timeout occurs, I call the stop() method of the thread to kill the thread.
    i used isAlive() method to check the thread status.
    i want to know if there is any other way to check if the thread is killed or not.

    In my application, i use threads.
    When timeout occurs, I call the stop() method of the thread to kill the thread.
    i used isAlive() method to check the thread status.
    i want to know if there is any other way to check if the thread is killed or not.

  • Thread status while waiting

    Hi,
    I need to know the thread status after calling wait() and before getting the notify() or notifyAll(). Is the sttaus "blocked" or "runnable"?
    Fore example, I know that the sleep() makes the threads "blocked".
    Thanks,
    Nuha

    Read the documentation for the Thread.State enum.
    The state is WAITING when doing Object.wait(), and also for doing a sleep()
    The state BLOCKED is reserved for when trying to acquire a monitor lock.
    Which "state" are you referring to? That obtained by getState() or that printed in a thread-dump? The thread state shows the "OS state" plus the same as getState().
    Message was edited by:
    davidholmes

  • Thread Status Icon Problem

    Hi,
    A problem that I have been facing for quite a while now is that several threads appear with the status icon which means that "Threads whose contents have changed since my last visit (semi orange icons)" but the issue is that I have never visited those threads. So how come they are marked with such a status (they should just be white icons).
    Please check this out
    Regards

    A problem that I have been facing for quite a while
    now is that several threads appear with the status
    icon which means that "Threads whose contents have
    changed since my last visit (semi orange icons)" but
    the issue is that I have never visited those threads.
    So how come they are marked with such a status (they
    should just be white icons).Mmmm shouldn't then they be orange if youv'e never visited them?
    OK I also sometimes have problems, I log in and got a big list of unread or semi-unread threads. And suddenly somewhere in the middle of all them one or two that are white showing that I've completely read them. But it is not possible, unless of course someone other is not working under my account which I hope is not true ;)
    Probably someone just edited the post and it doesn't mean that thread has been updated?
    Anyway to be frank for me this possible bug is on a very low priority because it happens quite rare and the problems coming out of this are quite tiny. I'd classify this bug as "cosmetic" ;)
    Gints Plivna
    http://www.gplivna.eu

  • Threads from the corba threadpool can take a long time killing

    I'm using the bounded threadpool (well, actually, I have changed the default unbounded threadpool to a bounded one and injected it using the endorsed dir mechanism - but the behaviours was the same before I did that - except that I then had 32000 threads in some cases) for handling corba events I receive from an ORB. I can see the number of threads increase and decrease as expected based on the load.
    However, sometimes everything hangs: The GUI freezes, I start loosing network packages and other unfortunate things occur. This coincides with the removal of threads (according to YourKit), e.g. last evening the removal of 14 threads took ~30 seconds and during that time absolutely nothing else appeared to happen. My two other Java processes were also for all intents and purposes dead (also according to YourKit) during that period.
    Is this related to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=1194877 in any way? This seems such a long standing issue that I find it hard to understand that this has not been resolved in any way. Is there a way around this problem?
    If it's not related, what can it then be? I'm not even sure where to look? Is it the Java implementation, the linux kernel, some combination with the hardware?
    I'm using SUNJava 1.5 u10 on Fedora Core 5 linux kernel 2.6.18-1.2239.fc5 on AMD64 hardware.

    Follow-up to myself since no-one else has replied:
    Could it be related to this bug [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6372405] and if it is, does the poster mean JDK 6, NOT 7?

  • Thread status doesn't change

    If I read thread and leave it then status (red ball next to thread name) should be white, but it isn't. Somebody knows why. It helps reading thread.
    Peter D.
    I noticed that in SQL\PLSQL forum. In this forum if I leave thread red ball changes to while to last visited thread.
    Message was edited by:
    Peter D.

    See Content indicator

  • How To  Identify thread status

    Hi Everybody,
    Anybody got an idea regarding identifying the status of the Thread like if its dead or live.
    And also how can you identify a thread.
    Very urgent,
    Thanks in advance.
    Keep smiling.....:-)

    try this
    public class ThreadTest implements Runnable {
    public static void main(String[] args) {
    ThreadTest tt = new ThreadTest();
    Thread t1 = new Thread(tt, "First");
    t1.setDaemon(true);
    Thread t2 = new Thread(tt, "Second");
    t2.setDaemon(true);
    t1.start();
    t2.start();
    try {
    Thread.sleep(2000);
    System.out.println("the first Thread is sleeping for 2 seconds");
    } catch (Exception e) {}
    synchronized (tt) {
    tt.notify();
    try {
    Thread.sleep(1000);
    System.out.println("the second Thread is sleeping for 1 second");
    } catch (Exception e) {}
    public synchronized void run() {
    try {
    wait();
    } catch (InterruptedException ie) {}
    sleepAWhile(4000);
    protected synchronized void sleepAWhile(long time) {
    try {
    Thread.sleep(time);
    } catch (Exception e) {}
    }

  • Stopping thread with timeout using threadpool

    Is there any way to set thread timeout within Executor.newFixedThreadPool ? I have a long queue around 5M which is creating with:
    ExecutorService executor = Executors.newFixedThreadPool(500);
    total = 10000;
    while (totalRows > 0) {
                    localStatement.executeQuery("SELECT domainID, domain FROM com WHERE status = '' LIMIT " + total);
                    totalRows -= total;
                    localResultSet = localStatement.getResultSet();
                    while (localResultSet.next()) {
                        HttpGet httpget = new HttpGet("http://" + localResultSet.getString("domain").toLowerCase());
                        executor.submit(new GetThread(httpClient, httpget, localResultSet.getInt("domainID")));
                    Thread.sleep(1000);
                    while (((ThreadPoolExecutor) executor).getActiveCount() > 10) {
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                    localResultSet.close();
                    System.out.println("New cycle");
                }But sometimes threads lock and cycle can't finish. Is there anyway to stop thread after N seconds? I can encapsulate Runnable into another Runnable and stop it from there, but it doubles threads, and I believe its not a good way.

    yes, you need at least one more thread. you could use one thread to monitor multiple other threads, but you need at least one more thread to wake up after the timeout and check on/cancel the main task.

  • [SOLVED] Tracking thread status

    Warning: This is a basic question. I may seem silly for asking this. :-P
    What is the best way to track the status of threads that I create? I see that you can "subscribe" to threads, but is there a page that lists all threads I have posted in, along with notifications for updates in those threads?
    I was thinking something along of the "Track" system Drupal provides, but I can't find something like that anywhere...
    Last edited by jalu (2010-08-14 21:38:41)

    Ahh, thank you everyone. Again, I'm sorry this was such a basic question, but I'm not terribly familiar with FluxBB (though it is very nice). For anyone who comes across this later, here's what I did...
    1. Navigate to Profile > Privacy. Check "Automatically subscribe to every topic you post in."
    2. Near the bottom of the forum, hover your mouse over the text "Show your subscribed topics". Copy the link location. Do not click the link and then copy the URL in the address bar, as the link redirects you to a temporary page that will not update to show new posts that you make.
    3. Thread updates are marked by a solid blue box to the left of the thread name.
    Thanks again, everyone!
    Last edited by jalu (2010-08-14 21:28:43)

  • How to know threads status

    Hello all!
    I want to know if all my threads are done.
    I wrote some code but when I run it have this errors:
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalMonitorStateException
            at java.lang.Object.wait(Native Method)
            at java.lang.Object.wait(Object.java:485)
            at gui.start.insertUserOpinion(start.java:177)
            at gui.start.searchButActionPerformed(start.java:145)
            at gui.start.access$000(start.java:36)
            at gui.start$1.actionPerformed(start.java:68)In my code I want to continue on my main function.
    my code is:
         //creating threads by index of combobox
         for (i=0;i<=level.getSelectedIndex();i++){
         new myThread(list.get(i).toString(),model);
         //wait until all threads are done
         while  (myThread.activeCount()!=0)
         this.wait();
         }The error on the while loop
    thanks for helping!!!

    vitaly87 wrote:
    But how do I know if all threads are done?When you have join()ed on each one of them. Like for example with your for loop there.
    if I have more that one thread,and i create them with simple program not with anther thread.What?

  • Determine Thread status

    Hello,
    I have two classes,a class extending a thread(called MyThread and a class that creates an instance of MyThread(called MyMain).How can I determine if the MyThread object is currently sleeping?Is it through isInterrupted?
    Thanks,

    You seem to be grasping at straws... Some solid research and reading should help you out.
    http://java.sun.com/docs/books/cp/
    The authors site....
    http://g.cs.oswego.edu

  • Thread status in jdb

    I'm trying to track down a possible memory leak, and am using jdb to look at my process. In it, I'm finding a lot of threads of a particular type that are in state "unknown". Does this imply that they have exited, but not been garbage collected, or are they hung for some reason?

    I'm on solaris 8, JRE is 1.3.1_06.
    Here is a sample run, showing one thread in the condition I'm seeing. Over the course of a week, thousands of these build up. The line in question is:
    (com.patagonia.www.gcs.GCSRequestor)0x27 Thread-286 unknow
    This class extends Thread, has a return in a finally block in the run method, and as far as I can tell, are stopping, but then not disappearing from the system.
    Initializing jdb...
    threadsGroup system:
    (java.lang.ref.Reference$ReferenceHandler)0x3 Reference Handler cond.
    (java.lang.ref.Finalizer$FinalizerThread)0x4 Finalizer cond.
    (java.lang.Thread)0x5 Signal Dispatcher cond.
    (java.lang.Thread)0x6 AdapterThread cond.
    (java.lang.Thread)0x7 CompileThread0 cond.
    Group main:
    (java.lang.Thread)0x1 main runnin
    (com.caucho.util.Cron$CronThread)0xc resin-cron cond.
    (com.caucho.util.Alarm$AlarmThread)0xd resin-alarm cond.
    (com.patagonia.www.gcs.GCSRequestListener)0xe GCSRequestListener runnin
    (com.patagonia.www.gcs.GCS400PacketHandler)0xf Thread-261 cond.
    (java.lang.Thread)0x10 Thread-263 cond.
    (java.lang.Thread)0x11 Thread-266 runnin
    (java.lang.Thread)0x12 Thread-267 runnin
    Group tcp-server:
    (java.lang.Thread)0x18 tcp-accept-6802 runnin
    (java.lang.Thread)0x19 tcp-accept-6802 cond.
    (java.lang.Thread)0x1a tcpConnection-6802-0 runnin
    (java.lang.Thread)0x1b tcpConnection-6802-1 runnin
    (java.lang.Thread)0x1c tcpConnection-6802-2 runnin
    (java.lang.Thread)0x1d PoolScavenger0 cond.
    (java.lang.Thread)0x1e tcpConnection-6802-5 runnin
    (java.lang.Thread)0x1f tcpConnection-6802-10 runnin
    (java.lang.Thread)0x20 tcpConnection-6802-19 runnin
    (java.lang.Thread)0x21 tcpConnection-6802-22 runnin
    (java.lang.Thread)0x22 tcpConnection-6802-23 cond.
    (java.lang.Thread)0x23 tcpConnection-6802-24 runnin
    (java.lang.Thread)0x24 tcpConnection-6802-25 runnin
    (java.lang.Thread)0x25 tcpConnection-6802-26 runnin
    (java.lang.Thread)0x26 tcpConnection-6802-31 runnin
    (com.patagonia.www.gcs.GCSRequestor)0x27 Thread-286 unknow
    (java.lang.Thread)0x28 tcpConnection-6802-37 runnin
    (java.lang.Thread)0x29 tcpConnection-6802-41 runnin
    (java.lang.Thread)0x2a tcpConnection-6802-42 runnin
    (java.lang.Thread)0x2b tcpConnection-6802-43 runnin
    (java.lang.Thread)0x2c tcpConnection-6802-44 runnin
    (java.lang.Thread)0x2d tcpConnection-6802-45 runnin
    (java.lang.Thread)0x2e tcpConnection-6802-46 runnin
    (java.lang.Thread)0x2f tcpConnection-6802-47 runnin
    (java.lang.Thread)0x30 tcpConnection-6802-48 runnin
    (java.lang.Thread)0x31 tcpConnection-6802-49 runnin
    (java.lang.Thread)0x32 tcpConnection-6802-50 runnin
    (java.lang.Thread)0x33 tcpConnection-6802-51 runnin
    (java.lang.Thread)0x34 tcpConnection-6802-52 runnin
    (java.lang.Thread)0x35 tcpConnection-6802-53 runnin
    (java.lang.Thread)0x36 tcpConnection-6802-54 runnin
    (java.lang.Thread)0x37 tcpConnection-6802-55 runnin
    (java.lang.Thread)0x38 tcpConnection-6802-56 runnin
    (java.lang.Thread)0x39 tcpConnection-6802-57 runnin
    (java.lang.Thread)0x3a tcpConnection-6802-58 runnin
    (java.lang.Thread)0x3b tcpConnection-6802-59 runnin
    >

  • Thread management in servlet

    Here is the problem that i am trying to solve - and get better understanding of issues to look out for.
    1) Problem to solve
    Clients sends an http request to an distributor server. The request contains a list of tasks. Each such task can be sent to a particular handling server (out of a known set) which can handle the request. Each task has a task type, which identifies which server the request needs to be passed to. The responses from the handler servers are then to be collected and passed back the client as a consolidated response.
    On the distributor server, the servlet thread that is handling the request will
    a. need to spread the requests for various handling servers
    b. send the requests in parallel to handling servers
    b. get all the responses , consolidate and send back
    2)Proposed solution
    I was thinking of having a thread pool - one thread for each handling server, initialized within servlet . When the distributor server receives a request - the tasks would be spread to these handling threads. The distributor thread would then wait, until the handling threads notify.
    When a notification is received - the distributor thread will need to check if all responses are received. If not - it would need to wait (till a max_timeout) else return the response to client
    3)Questions
    - This involves waiting on the thread created by serlvet container (the distributor thread) and creating a threadpool. Thread creation and management by application in web-container is generally dissuaded - but given this issue - i see no other alternative
    suggestions ? Its been a long email - thanks for considering
    Fred

    How many clients for the entry server do you presume for the application ? I ask this because it is very possible that the server to remain without available threads and give errors. If you use different servers for the final requests I suppose that are some very time consuming processes. What kind of application are running on these servers so that you want to use this kind of distributed computing ?
    Why did you choose as an entry point a servlet container and http request for this kind of problem ? Do you need a graphic response in the browser ? If the response time is too long, the browser (Internet Explorer) will show exception and will not wait for the response (for this you must set some variabiles on client). Also the J2EE server must be set so that not to throw a time-out exception.
    To prevent these, you could do so that not to block the distributor thread and let it send the answer back to the client. Then you can tell to client browser to query the server from time to time to check the status of the execution (you can do that from javascript). When the execution is ready you can retrun the response to the client. Doing this way you will not block the application server threads.
    Now in the back end, you must somehow to take some identificators from the processes and sent them back to the client.
    You can use a database to make the bridge between the central server and the other processes (here you can put the processes identificators). When the processes end up they update their results in the database.
    The client, when will make the repetitive requests, will check the status of the processes in the database with given identificators.
    Sounds like an interesting project.

Maybe you are looking for

  • Best MPEG Streamclip settings

    I've looked at the prior discussions of this subect on these forums and they are several years old, therefor may not be accurate for FCPx, and some refer to screenshots of settings which are no longer available. I am having to import video from disc

  • BPEL in Weblogic Server

    Hi, I am trying to install BPEL in weblogic server but i am not succesful. 1. Intall BPEL PM 2. Path apllied for BPEL PM 3. IRCA - repository created 4.weblogic server installed 5.orabpel installed. after that i checked the logs. below is the log mes

  • Querying instances in 11g and filtering by process data object

    Hi all, I have tried to query instance following this link: http://soadev.blogspot.com/2011/07/querying-oracle-bpm-process-instances.html. It works fine, but I need to filter the instances by a process data object with a String type. Is it possible t

  • Retina Macbook Pro slow with photshop actions.

    Hi everyone just wondering if anyone has an answer to this question. I have the 2.6 Retina with 16GB of ram When I run Photoshop cs6 actions they are taking around 30 seconds to run but on my 3.2GHz 2008 Mac Pro they take around 11 sec. Is this to be

  • Where are nokia email files are stored

    i want to save my phone memory because i have 4GB card I want to save all my email nd messaging data on card. So where are the emails store if my msg settngs are set to phone memory if i set it to memory card all the emails will be saved in card? Ano