Java threads monitoring

I am using Java threads in my Java program, running on Windows Professional 2000. I am monitoring the threads using Windows Performance Monitor (WPM). However, even running a small Java program which creates only 2 threads, results in many (at least 10) instances of Java threads being reported by the WPM. Problem is, in WPM, there is no way to determine which threads in the WPM are the threads that I programmatically created. Any ideas on how to determine this?
Thanks.
Rhodie

Hi Dmirty ,
To handle large asynchronous message   in queues you can use  message packaging where multiple message are processed in one package . to make it applicable you have to perform these simple steps
1. go to SXMB_ADM add one RUNTIME parameter PACKAGING and value 1
2 GO TO transaction SXMS_BCONF set delay time 0 message count 100 messages and package size 1000 KB
with these setting your improvement will increase .secondly also put  IN SXMB_ADM monitor category parameter QRFC_RESTART_ALLOWED TO 1
this will automatically start your queue . Only thing you have to take care if you enable packaging them don't keep too many parallel queue i.e EO_INBOUND_PARALLEL and EO_OUTBOUND_PARALLEL should be less than 20
Regards,
Saurabh

Similar Messages

  • How can I get the memory allocation info of a java thread?

    Now I am going to write a program to monitor the execution condition of the java threads. But it seems that the classes in standard edition of JDK does not provide facilities to get the information such as the memory allocation and CPU time of a running thread. How can I do with it? Can I use JNI or JVMDI to get them? If it could do, how?

    Thanks a lot. I just browsed the specification of jvmpi. It is interesting and it seems that I can get the information I need. However, if I want to get the information in my program, I mean, if I want to build a class which may use JNI method to invoke the function written with JVMPI, and then forward the data to other upper layer objects, can it be done?

  • Synchronized thread monitors!!! AHHH!!!

    Hi,
    In my program , I'm trying to start a thread which immediately begins waiting and when a notify is received the Thread executes a method and then right back to waiting. The program I'm having trouble writing is far too bulky and complicated to be easily made sense of here, so I've written this concise version:
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    import java.util.*;
    class syncTest1 {
         public static void main(String[] args) {
              syncTest2 thread = new syncTest2();
              Monitor monitor = new Monitor();
              try {
                   for(int i = 1; i <= 100; i++) {
                        synchronized(monitor) {
                             System.out.println("Notifying...");
                             monitor.notify();
                             Thread.sleep(500);
              } catch(InterruptedException ie) {}
    class syncTest2 extends Thread {
         Monitor monitor;
         syncTest2() {}
         public void run() {
              try {
                   while (monitor.progress() < 100) {
                        synchronized(monitor) {
                             monitor.wait();
                             monitor.increment(1);
                             System.out.println("Notified! Progress = " + monitor);
              } catch(InterruptedException ie) {}
         public Monitor getMonitor() { return monitor; }
    // Used to store a dynamic integer value that can passed around as a synchronized monitor
    class Monitor {
         int Int;
         Monitor() { Int = 0; }
         public void increment(int howMuch) { Int += Math.abs(howMuch); }
         public void decrement(int howMuch) { Int -= Math.abs(howMuch) * -1; }
         public  int progress() { return Int; }
    }<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    When ran, this is the output:
    java syncTest1
    Notifying...
    Notifying...
    Notifying...
    Notifying...
    Notifying...
    Notifying...
    Notifying...
    <and so on>
    Notice how the monitor is never notified and syncTest1's monitor is still reacquired and able to be notified. I assume the problem lies somewhere in the trading of the monitor between classes, but for the life of me, I can't figure this one out...
    Any help at all would be appreciated.
    Thanks,
    Jick

    There are 2 things wrong.
    1) You did not start your your thread.
    2) You were not synchronizing on the same object.
    I have also made some cosmetic changes but you are free to remove them.
    import java.util.*;
    public class Test20041229
        public static void main(String[] args)
            syncTest2 thread = new syncTest2();
            Monitor monitor = thread.getMonitor();//new Monitor(); !!!!!!!!!!!!!!!!!!!!!!!!!!
            thread.start(); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
            for(int i = 1; i <= 100; i++)
                synchronized(monitor)
                    System.out.println("Notifying..." + i);
                    monitor.notify();
                    try
                        monitor.wait(500);
                    } catch(InterruptedException ie)
    class syncTest2 extends Thread
        Monitor monitor = new Monitor();
        syncTest2()
        public void run()
            while (monitor.progress() < 100)
                synchronized(monitor)
                    try
                        monitor.wait();
                    } catch(InterruptedException ie)
                    monitor.increment(1);
                    System.out.println("Notified! Progress = " + monitor);
        public Monitor getMonitor()
        { return monitor; }
    // Used to store a dynamic integer value that can passed around as a synchronized monitor
    class Monitor
        int Int;
        Monitor()
        { Int = 0; }
        public void increment(int howMuch)
        { Int += Math.abs(howMuch); }
        public void decrement(int howMuch)
        { Int -= Math.abs(howMuch) * -1; }
        public  int progress()
        { return Int; }
        public String toString()
            return "Monitor(" + Int + ")";
    }

  • Java Threads not being released after loggin off

    Hello everyone,
    We are seeing a weird problem in our PI 7.0 box.
    Once I logout from the XI box (both ABAP and Java stck) my basis tem still sees Java threads aginst my id still open. Our system does not seem to be realeasing Java threads.
    Is this a know problem? What are the remidition steps.

    Hi,
    Are there existing HTTP sessions only?
    The following might be helpful.
    http://help.sap.com/saphelp_nw73/helpdata/en/c7/5ee440ba994fa3b187ff2f050cfe7c/content.htm
    http://wiki.sdn.sap.com/wiki/display/ERPHCM/Sessionnotendingafterlogoff
    Regards,
    Varun

  • Java Threads Problem

    Hi, I am trying to write a simple java threads program where in one thread reads a file and another thread writes the data into a second file....
    Here is my code, although i think i am correct, my program still runs in a sequential fashion help help help!!!
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    class MyThread extends Thread{
    private int a;
    private int c;
    FileInputStream in;
    FileOutputStream out;
    public MyThread(int a){
    this.a = a;
    public void run(){
    if(this.a==5)
         try {
         in = new FileInputStream("Britney.txt");
    } catch (FileNotFoundException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
    try {
         while((c=in.read())!=-1)
              a = (char) c;
              System.out.println(a);
    catch (IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
    if(this.a==10)
         try {
              out = new FileOutputStream("romi.txt");
         } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
         for(int i = 0;i<50;i++)
              try {
                   System.out.println(c);
                   out.write(c);
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    class MainMyThread{
    public static void main(String args[]){
    MyThread thr1, thr2;
    thr1 = new MyThread(5);
    thr2 = new MyThread(10);
    thr1.start();
    thr2.start();
    }

    Encephalopathic wrote:
    malcolmmc wrote:
    ... Chances of getting any kind of reply except "me too" can be pretty remote. ....there's actually a better chance of getting a reply on a general forum like this one, ....Can't you just post in both the narrow and the general forum, but include links one to the other in each thread? Or is that against the forum rules/etiquette? Most people here are ok with a crosspost IF those links are included.
    I would also ask that the OP designate one of those threads as the real discussion thread and just direct folks there from the other threads, so that we have one coherent discussion. If he does that, there's no problem with trying to reach out to as broad an audience as possible.
    I would figure that if the poster were upfront about what they are doing, folks wouldn't mind, but I could be wrong.I think that's generally the case. As long as the discussion is confined to one thread (and pointed there from the crossposts) or at the very least all the participants can see all the discussions, I think most people don't have a problem with it. It's when we waste our time answering when he's already got the answer elsewhere that's annoying.

  • Java thread not working in windows 7

    I have a Java app that runs just fine on Windows XP. However, on Windows 7 there is a problem related to a job being done via a Java thread.
    Background: The app spawns a separate job via a Java thread and continues on while the spawned job executes. In other words, 2 things happen at once.
    Problem: On Windows 7, when the app spawns the job, Windows sits and waits for the spawned job to complete before it continues on. In other words, 2 things DO NOT happen at once.
    It's as if Java threading does not work in Windows 7. Any input would be greatly appreciated. Thanks.

    l_sleven wrote:
    Thanks for the input, guys. From now on I'll be sure to include a SSCCE.
    I'm beginning to believe this is actually my ignorance of threading in SWT, and XP was more forgiving than 7.
    I would include a SSCCE, but of the 4 different ways I tried to get this to work I wouldn't know which to include since all failed to fix the problem.
    If you want to identify a link to a web page identifying 'best practices' for SWT threading, that would be great. Be aware though that there's a good chance I've already googled the page.
    A programmer smarter than me once said, "The road to best practices is a bumpy ride".[Concurrency in Swing|http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html]

  • Java thread with high CPU usage

    Hi,
    Running prstat -L -p pid on Solaris produces a list of lwp threads running in that process that are consuming the most CPU. Out of about 7 threads that were associated with kernel threads in pstack output, only 5 of them were mapped to a JVM thread dump. How is it possible to have a Java thread consuming CPU that doesn't show up in a thread dump?
    Thanks,
    J.S.

    And, any idea what this thread is doing?
    Here's pstack output for this missing thread 12:
    ----------------- lwp# 18 / thread# 12 --------------------
    fe0e48b4 __1cHCompileSflatten_alias_type6kMpknHTypePtr__3_ (b6001780, 100360, fe4c8000, b6001780, 100360, 0) + 4d8
    fe0f42ac __1cHCompilePget_alias_index6kMpknHTypePtr__I_ (b6001780, 100360, b6001264, 7e2bb8, 41f4, 7e2bb8) + 8
    fe11131c __1cJStoreNodeFIdeal6MpnIPhaseGVN_pnLPhaseDefUse__pnENode__ (0, 7dd5b4, 5035ec, 7e2bb8, b6001144, b6001264) + 128
    fe0c1224 __1cMPhaseIterGVNNtransform_old6MpnENode__2_ (0, b6001144, 7e2bb8, b6001264, 7e2bb8, b600116c) + 47c
    fe17349c __1cMPhaseIterGVNIoptimize6M_v_ (24, 0, a37700, b6001110, b6001100, 3442f0) + b4
    fe1943b0 __1cOPhaseIdealLoop2t6MrnMPhaseIterGVN_pk0_v_ (b6000ee8, a3772c, 1, 4ff37c, 2000, 269568) + 7cc
    fe1cc89c __1cHCompileIOptimize6M_v_ (b6001780, b60015b8, b6001780, b60015dc, 0, b60013dc) + a0
    fe1cb69c __1cHCompile2t6MpnFciEnv_pnHciScope_pnIciMethod_ill_v_ (91f504, b6001800, db8a24, fe5296b4, b60018a0, b60018b0) + 7bc
    fe1c73f8 __1cKC2CompilerOcompile_method6MpnFciEnv_pnHciScope_pnIciMethod_il_v_ (27b18, b6001af8, db8a24, db8938, ffffffff, 1) + 70
    fe1c79fc __1cNCompileBrokerZinvoke_compiler_on_method6FpnLCompileTask__v_ (db8938, db8a24, fe4eacec, 0, 0, 8d9) + 40c
    fe280964 __1cNCompileBrokerUcompiler_thread_loop6F_v_ (28758, 13a570, fe4c8000, b6001d10, fe4c8000, ffffffff) + 168
    fe216200 __1cKJavaThreadDrun6M_v_ (b5e02000, fe4d3e34, fe4c8000, 1ffd70, 13a570, 1ffd70) + 3d8
    fe213ec8 _start   (fe4c8000, ff325d10, 0, 5, 1, fe401000) + 20
    ff36b734 threadstart (13a570, 0, 0, 0, 0, 0) + 40

  • I want to execute other java thread in the JNI.

    Hi!
    I would like to execute other java native thread concurrently in the Java Native Interface.
    When a Java thread called a native thread to use java native interface, Java thread is blocking for processing native thread.
    So, other java threads don't execute because they are blocking.
    Why do these problems occur at JVM(personal basis profile:CVM)?
    I hope you explain this reason in detail.
    Regard.
    Message was edited by:
    peeppeep

    Cross post
    http://forum.java.sun.com/thread.jspa?threadID=786857&messageID=4471999#4471999

  • How to terminate a java thread from c++ code?

    Hi,
    I made a screensaver which loads a jvm, forks a thread running a java class, wait until user's action(i.e. mouse move/click keyboard input), then terminate the java thread.
    However, I met a problem, How to terminate a running java thread from c++ code?
    Here is my code, but it does not work: (even after the terminate is called, jvm throws an error)
    JNIEnv* env;
    JavaVM* jvm;
    HANDLE hThread; //handle for the startThread
    unsigned __stdcall startThread(void *arg)
         jclass cls;
         jmethodID mainId;
         jint          res;
         int threadNum = (int)arg;
         res = jvm->AttachCurrentThread((void**)&env, NULL);
    cls = env->FindClass( MAIN_CLASS);
         mainId = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");
         // setup the parameters to pass to main()
         jstring str;
         jobjectArray args;
         int i=0;
         args = env->NewObjectArray(1, env->FindClass("java/lang/String"), 0); //only one input parameters
         str = env->NewStringUTF("localhost");
         env->SetObjectArrayElement(args, 0, str);
         env->CallStaticVoidMethod(cls, mainId, args); // call main()      
         if (env->ExceptionOccurred()) {
                   env->ExceptionDescribe();
         return TRUE;
    Here is the main method:
    First create the jvm and load the thread. then tries to terminate the thread, but failed here
    switch (msg)
    { case WM_CREATE:
              JavaVMOption options[NUMBEROFOPTIONS];
              JavaVMInitArgs vmargs;     
              jint rc;
              vmargs.version = JNI_VERSION_1_4; /* version 1.4 */
              vmargs.options = options;
              vmargs.nOptions = NUMBEROFOPTIONS;
              vmargs.ignoreUnrecognized = JNI_FALSE;          
              rc=JNI_CreateJavaVM( &jvm, (void **)&env, &vmargs ); /* create JVM */
              /* We pass the thread number as the argument to the invoked thread */
              unsigned int threadId = -1;
              // to initialize a thread-safe C runtime library
              hThread = (HANDLE)_beginthreadex(NULL, 0, &startThread, NULL, 0, &threadId );
    } break;
    case (WM_DESTROY):
              CloseHandle( hThread );
              jvm->DestroyJavaVM(); /* kill JVM */
              Debug("Destroy Java Virtual Machine\n");
    }break;
    Note, after the thread "startThread" runs, it has an infinite loop and will not terminate, until the user clicks to terminate.(I didn't call jvm->DetachCurrentThread();_endthreadex(0); in the "startThread" because the java thread will not terminate by itself)
    Thus, the only way to terminate the thread is to call closehandle(hthread) in the main thread, which may cause jvm to throw an error.
    Do you know how to terminate a java thread safely???
    Thanks a lot

    Assuming that your java thread is in a loop of some kind. Such as
    int i=1; /* I tried using a boolean, I just could not get my C++ env, to change this value. So i decided to use an int */
    run {
    while(i)
    isdfjsdfj
    void seti()
    i=0
    So, B/4, i call destroyVM in my C++ code, i call this seti(). so the loop terminates, therefore my thread finishes executing and ends.
    Hope this helps
    tola.

  • Best option for Asynchronous method invocation? JMS or Pure Java Thread

    Hi,
    We've a swing based Client application which is supposed to run with a server in J2EE environment. Some process like Search etc are very time consuming. So we are going for asynchronous process.
    Now the question is to find a best option for this. Two possible candidates are
    1. JMS
    2. Java Thread.
    Can anybody suggest me which one is the best option in this context?

    Actually my thought was the issues with code maintainability.Maintainability is different issue, it is much related to OOAD and design pattern you might want to choose to avoid coupling (thus high reusability and maintainability - eg: for future enhancement, etc)..
    public interface SearchService {
         public static class DefaultFactory {
                 public SearchService getInstance() {
                          return HttpSearchService.getInstance();
         public void search (String[] keywords, Observer obs);
    public class HttpSearchService implements SearchService {
         public static HttpSearchService getInstance() {
                ... bla bla bla singleton ...
         public void search(final String [] keywords, final Observer obs) {
                     (new Thread() {
                              public void run() {
                                    .. do http request ...
                                    List result =  ... parse http response ...
                                    obs.update(list);
                     }).start();
    SearchService ss = SearchService.DefaultFactory.getInstance();
    ss.search( new String[] { "get", "me", "my" , "dukes" }, myTableModel );
    ...You can, in future, replace the default factory HttpSearchService with something faster, more appropriate SearchService, without changing many codes.
    rgds,
    Alex

  • Multiple java threads in a JVM created by the invocation interface

    Hi,
    I have a certain application APP that calls functions of a C library. One of these functions creates a JVM through the invocation interface. In the JVM I create some other threads and a Swing GUI. From the java "main" thread as well as the other threads (including the Swing event dispatcher thread) I need to call dll functions through native java methods. The latter indirectly (through another dll) invoke functions of an API of application APP.
    I have problems when making calls from the java threads to the java native library. In some cases everything works well i.e., I'm able to make calls to the java native library from both the "main" java thread and the other threads. In other cases a crash occurs when attempting to access the native library from any threads but the "main" thread.
    Can anyone help me on this? Is there any requirement that only the main java thread makes callbacks to C code?
    Thanks.

    > why later sets of java application is taking longer?
    Probably because of CPU usage.  But could be memory.
    >Can I do something here so that later sets of apps also completes in 3 mins
    You tune the task, the complete task, to the box.  That means you must understand in detail what is taking time and then architect that to make the best use of the available CPUs and memory (and other resources as used by the task.)

  • How to use Java threads in ColdFusion

    Hello Everybody,
    I have a question in concerns to threads. We all know that in
    CF8 we have this fantastic tag called <cfthread> which give
    us the ability to create assyncronous code, however, I was
    concerned about earlier versions of ColdFusion, like CF7 and CF
    6.1.
    How can I create a Java thread and use it in my CF code?
    Please, any help is much appreciated. Thanks in advance.
    Alvaro Costa
    Systems Analyst
    [email protected]

    A bean is obtain by <jsp:useBean> tag nd once bean is obtained we can get its property by using getProperty tag.

  • Use java thread? or Oracle DB scheduler?

    I have a java thread which purge records in a table every 30 seconds. The thread calls a prepared statement which is like "delete from MyTable where status=99"
    can I use DB's scheduled job to do the same thing? I can create a DB schedule, and a job in plsql.
    Thus I can save on DB connections.
    Which one is better in terms of performance?

    SoulTech2012 wrote:
    i personally recommend against PL/SQL if you can manage it
    some will argue that it's okay to couple yourself to a database because you're likely not to change it
    but i've seen enough migrations to know the painConversely I have seen attempts to process data by dragging it across the network in the vain attempt to make the application database agnostic. Which results in orders of magnitude more processing time when the application needs to do anything approaching real volume.

  • Help calling JNI function from a java thread

    I am using the following code to call a JNI fuction from a java thread:
    public class CMSMessageHandler extends MessageHandler{
    static{
    System.loadLibrary("jastb");
    public native int cmsReadIt(ByteBuffer buff);
    private ByteBuffer dirbuf = null;
    /** Creates a new instance of CMSMessageHandler */
    public CMSMessageHandler() {
    // allocate to max size datagram
    dirbuf = ByteBuffer.allocateDirect(65536);
    public void readMessages(){
    /*Thread worker = new Thread(){
    public void run(){*/
    int count;
    while (true){
    try{
    count = cmsReadIt(dirbuf);
    } catch (Exception e){
    e.printStackTrace();
    worker.start();*/
    public static void main(String[] args) {
    CMSMessageHandler handler = new CMSMessageHandler();
    handler.readMessages();
    When I run this main method with the thread commented out, it works great. When I run the main method with the thread, it works great for a while, and then funny things start happening with the native library I am using. My native library uses shared memory, signals, and semaphores. It feels a bit like my java program is stomping on the resources that my native library is using, when a run the java program with a thread.
    Is there something I don't know about calling native code from a thread? Should I be doing something explicitly to protect my native library's shared memory, signals, or semaphores?
    Thanks,
    Lisa.

    Does the library do any initialization when loaded? Does it make a dangerous assumption that the thead calling cmdReadIt will always be the same thread that initially loaded it? Try loading the library in the worker thread instead of in the main thread via the static initializer.Yes. There is a call to another native method cmsOpenIt that does CMS initialization. I put cmsOpenIt as well as the System.loadLibrary("jastb") in the worker thread and I'm still experiencing the same problems.
    Incidently, the mere presence of another Thread in this program does not seem to cause problems. It's only when I run calls to cmsReadIt in a thread that I get into trouble.
    For example, this works fine:
    public class CMSMessageHandler extends MessageHandler{
        public native int cmsReadIt(ByteBuffer buff);
        public ByteBuffer dirbuf = null;
        static {
            System.loadLibrary("jastb");
        public CMSMessageHandler() {
            // allocate to max size datagram
            dirbuf = ByteBuffer.allocateDirect(65536);
        public void readMessages(){
            try{
                int count = 0;
                while (true){
                    count = cmsReadIt(dirbuf);
            } catch (Exception e){
        public static void main(String[] args) {
            CMSMessageHandler handler = new CMSMessageHandler();
            Thread worker = new Thread(){
                public void run(){
                    while (true){
                        try{
                            Thread.currentThread().sleep(1000);
                            System.out.println("sleep thread.");
                        } catch (Exception e){
                            e.printStackTrace();
            worker.start();
            handler.readMessages();  
        }Are there JVM flags that I should experiment with that might help mitigate/diagnose this problem?

  • Calculate elapse time of a Java thread  before execution

    Hi,
    I would like to enquire how can I calculate the elapse time of a Java thread BEFORE this thread is executiing or running.?
    I wish to estimate the elapsed time of each Java thread before execution to better schedule these threads to run on multiple processors for load balancing testing.
    Please help
    -meileng-[                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You can grab the system time in the initiating thread immediately before calling start(), and as the first step in run() in the new thread.
    However, this measurement is utterly meaningless, as it can vary between architectures or even between consecutive runs on the same box. Furthermore, even once a thread starts, it may do nothing more than that one grab-the-system-time instruction before it get swapped out for a theoretically unbounded amount of time.
    By definition, if you spawn multiple threads in Java, you don't know or care which one get CPU time when, except as you control by syncing, sleep, wait, notify, notifyAll, and whatever control priorities give you. Additionally, you don't know when the OS will give your VM cycles, and on multi-CPU machines, you don't know how many CPUs it will get when it does get cycles.

Maybe you are looking for