Threading issues - Best way to debug

Hey everyone... I have a small server program that I wrote in Java. Its module based where each thread that is created runs through a list of modules and returns the output. It works just fine and I am doing a little stress test using Siege. I set it up running 50 concurrent users with no delay and take millions of requests with no errors at all.
However, when I move it up to 125 concurrent users, I start getting NullPointerExceptions on a fairly routine basis (inside of one of the modules). The server is still running with no issues, just with that many users it appears to have a bug.
I was wondering what the best way figure out why this would be happening. Or is this kind of thing to be expected and I should just implement some method of throttling for the threads. I plan to do that eventually, just trying to get the bugs out first.
Thanks in advance!

I think you are seeing the NPE concurrent scenario because of the assumptions you code is making about how JVM should behave. You code may be making assumption of "happens-before" pattern which may seem valid when you look at the code, but in fact are not.
Take a look at this presentation that outlines the Java Memory model and defines the contract between concurrent programs and JVM.
http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=TS-1630&yr=2006&track=coreplatform
Throttling the method is a bad idea (and a cop out). How would you arrive at the optimal number threads that can safely access your program ? Will your code be portable when it is deployed on a computer with different computing power than what you are testing on ?
Hope this helps.
-Prashant

Similar Messages

  • Best way to debug KDE process crashes

    I've got a relatively fresh install of ARCH with KDE running.  However every time I reboot and log in I immediately get 2 pop-ups stating that KMix and a KDE Deamon closed unexpectedly.  The "executable" for both is listed as kdenitit4.  I'm assuming that is the app that started the failed process?  Checking the PIDs for each in the process list before closing the pop-ups show kmix and kded4 as the actual stopped processes.
    Question then, what is the best way to debug this.  I know there are system logs but I'm really not that familiar with where or what to look for and really want to learn and also fix the crashes :-)   What is the best way to start.  Thanks,
    John.........

    Here is some of the lines around the 2 KCrash errors:
    Known subscriber "AkonadiAgentServer" subscribes again
    void Akonadi::NotificationSource::addClientServiceName(const QString&) Notification source "AkonadiAgentServer" now serving: (":1.48", ":1.47")
    Known subscriber "AkonadiAgentServer" subscribes again
    void Akonadi::NotificationSource::addClientServiceName(const QString&) Notification source "AkonadiAgentServer" now serving: (":1.48", ":1.47", ":1.49")
    Database "akonadi" opened using driver "QMYSQL"
    Database "akonadi" opened using driver "QMYSQL"
    Known subscriber "AkonadiAgentServer" subscribes again
    void Akonadi::NotificationSource::addClientServiceName(const QString&) Notification source "AkonadiAgentServer" now serving: (":1.48", ":1.47", ":1.49", ":1.46")
    plasma-desktop(889)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
    >> KCrash: Attempting to start /usr/bin/kded4 from kdeinit
    knotify(887)/phonon (KDE plugin): QDBusError("org.freedesktop.DBus.Error.NoReply", "Message did not receive a reply (timeout by message bus)")
    korgac(944)/kdecore (K*TimeZone*): KSystemTimeZones: ktimezoned initialize() D-Bus call failed: "The name org.kde.kded was not provided by any .service files"
    knotify(887)/phonon (KDE plugin): QDBusError("org.freedesktop.DBus.Error.ServiceUnknown", "The name org.kde.kded was not provided by any .service files")
    QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
    kdeinit4: hcontrol.c:764: snd_hctl_handle_event: Assertion `elem' failed.
    QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
    >> KCrash: Application 'kded4' crashing...
    KCrash: Attempting to start /usr/lib/kde4/libexec/drkonqi from kdeinit
    [0x2853108] main input error: ES_OUT_RESET_PCR called
    KCrash: Application 'kmix' crashing...
    KCrash: Attempting to start /usr/lib/kde4/libexec/drkonqi from kdeinit
    Known subscriber "akonadi_maildispatcher_agent" subscribes again
    Known subscriber "akonadi_maildispatcher_agent" subscribes again
    Agent instance created in separate process.
    I marked the original two KCrash's with >> to make them easier to find.  Looking a few lines down from the 2nd one I also see a KCrash for 'kmix' which is also part of the problem.  Don't really see anything else interesting.  Open to ideas.  Thanks,
    John...........

  • Best Way to Debug an Inbound IDoc

    Hi
    As previous posts suggest I am having trouble with IDoc PORDCR101 message type pordcr   bapi_po_create
    i input
    comp code 3000
    doctype      NB
    vender        58121
    purchorg     3000
    purchgrp     000
    doc date     01112007
    item           0010
    material     scw1212
    qty            0001000.000
    currency    USD
    scheduleitem  0010
    deldate           01/18/2007
    qty                 0001000
    i put this exact info in se37 with bapi_po_create
    I can successfully create a new po
    now i try to do the same thing in we19 standard inbound
    using idoc pordcr101
    each time i try i get status 51 enter purchasing org
    what is the best way to debug this thing so that i can see what is going on
    i am entering the purchasing org and for some reason it does not see it
    what can i do in the way of debugging?????
    HELP!!!!!!

    Janice,
    conversion-exit routines are used when the contents of a screen field(SAP GUI) are converted from display format to SAP-internal format and vice versa.
    --Archana

  • The best way to debug a deployment

    I have an application written in JDeveloper and it runs like a dream. The problem is that when I deploy it to Oracle App Server, I cant get it to run. I am using the JDeveloper deployment profile for creating my jars/wars/ears. I have build many of these in the past and they all work well. There is obviously something I am doing wrong with this one. How can I go about debugging my deployment. I've been stuck on this one for a long time and need to make some progress. Please help.
    Thanks,
    Cory

    In my personal opinion there is no "best" way, but here's what I always do:
    1. Check main settings
    2. Check main logfiles
    3. Check database
    First you have to check the main settings, like data sources, OC4J-settings and JVM-settings. A type-o in your settings could kill your deployment. Also, if you are using jms, make sure that the correct topics are registered in jms.xml If all is o.k., then proceed to step 2.
    Secondly you should check the standard out for the OC4J where you are deploying the application. This is located at $ORACLE_HOME/opmn/logs/$OC4J_NAME_default_island_1. You can also redirect the standard out by setting de -out parameter in the server settings. This should also contain some helpfull clues (like missing references to property files, typ-o's, wrong classpath, etc.)
    Finally if all this is OK and you application still isn't starting (but by then it is deployed) you should check the state of the database. It should be up and running, and containing the correct version of the application's datamodel. Removing rows from quartz tabels (if used) also helps while redeploying.
    This is roughly my starting debugging route. Does this give you any pointers?

  • Concurrancy issue best way to handle it?

    Hi there,
    I have an application which is processing a group of commands.
    while(.....)
    //process command here...
    switch(command)
    case blah
    case blah
    This loop will continue executing until it reachs the end of the group. Now in some commands I need to spawn a timer which does some processing. However since I have spawned the timer(must use a timer) obviously control goes back to processing my command loop. I need to some how stop my command processing until the timer event has finished.
    What are your views on the best way to achieve this? Im thinking about the timer setting some global var which when set will keep the application in a loop but im sure this isnt the best way to do this.
    What are your thoughts and suggestions?

    I think it is the place using wait( ) and notify( ) in Object.
    PC

  • Best Way to debug Javascript

    Hi,
    I have a random bug in Javascript which locks the loaded page
    sometimes when i executed the pages outside Dreamweaver. What is
    the best way to denug?
    Thanks.

    Found that microsoft provides a script debugger.. 
    Thanks..

  • Multipe threads access: best way to handle

    Hi,
    I understand that we have issues when multiple threads access the instance variables in a servlet. Do we have the same issue with the local variables? I have a doGet method that has two lines of code.
    line 1: read request parameters and create a data object.
    line 2: make a call to facade to update this object in database.
    What options I have to make sure that there are no concurrent access issues.
    -Deepak

    No, you don't have the same issue with local variables, new ones are created for each thread. You should either avoid adding attributes to a servlet, or synchronize access to them if they are objects (there are no issues with primitive values).

  • Threaded logging - best way to implement?

    Hi everyone, I am trying to get my head around threads.
    I am writing a log application that will either write to a text file or to a document in a Notes database. I don't want the main class that calls the log to wait for saves, so I am considering making the log class run its own thread.
    My first question is should Log extend Thread or implement Runnable?
    The second question is if I want to save the log document or flush the printwriter every 20 seconds in its own thread, will I need a further worker thread to do this? I imagine the worker thread would loop continually and every 20 seconds would perform a save. Or is this possible within the main Log class? Do I need to use a Timer?
    If anyone has a link to some good tutorials on threading I would be very grateful as its beginning to make my head hurt! :)
    Many thanks
    Marc

    Definately read up on it, but basically only one thread can enter a synchronized block at a time. The reason behind it is to prevent data corruption (among other things) by multiple threads executing on the same shared data. When a thread enters a synchronized block it obtains a lock on that Object. No other thread can get that lock until the first thread leaves that synchronized block.

  • Best way to create vertical slide navigation

    I would like to create a nice navigation that opens up vertically to help users get around. What is the best way to do this?
    Thanks!
    Van

    Hello,
    The rollover or dropdown menu will be the biggest issue, best way to realize that would be using a widget. I have been trying for another user to create a flyout menu, using effects triggered by advanced actions, but was not able to have this functionality more than once.
    There are some widgets coming with Captivate: did you have a look at the 'GotoSlide_AS3' widget:  it allows you to type in precisely the slides you want to offer navigation to.  It will not dropdown on rollover, user has to click.
    I do not understand your other wish: you do not want all the slides ready in the menu, only the ones that have already been visited? What if they did not visit anything yet, what do you want to show up for navigation? Which links should be disabled?
    Lilybiri

  • I had to reset my iphone 5 today because of software issues. what is the best way to restore all my apps?

    I had to reset my iphone 5 because of corrupt software issues. now I am trying to restore my apps. So are returning. Some are not. Some are making me pay for them again! What is the best way to restor all the apps?

    Sync them from your computer back to the iphone

  • What is the best way to deal with memory leak issue in sql server 2008 R2

    What is the best way to deal with memory leak issue in sql server 2008 R2.

    What is the best way to deal with memory leak issue in sql server 2008 R2.
    I have heard of memory leak in OS that too because of some external application or rouge drivers SQL server 2008 R2 if patched to latest SP and CU ( may be if required) does not leaks memory.
    Are you in opinion that since SQL is taking lot of memory and then not releasing it is a memory leak.If so this is not a memory leak but default behavior .You need to set proper value for max server memory in sp_configure to limit buffer pool usage.However
    sql can take more memory from outside buffer pool if linked server ,CLR,extended stored procs XML are heavily utilized
    Any specific issue you are facing
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Best way to stop or kill a thread

    hi what would say is the best way to kill a thread in this situation.
    1. I have 200 threads
    2. Each Thread has a reference stored in a hashtable example;
    for( int i=0; i<200; i++){
    Thread t = new exThread(i);
    hashtable.put(Integer(i) , t );
    t.start();
    each thread is running in an infinite while loop.
    now what would you say is the best way to kill the thread from this parent class.
    One thought of mine is to access get the reference and call stop.
    example;
    Thread tRef = hashtable.get(Integer(100));
    tRef.stop();
    In the stop method i would clear up whatever it was doing - release resources properly and - when it goes out of the stop scope , i'm guessing it would be destroyed.
    Any thoughts or other recommendations ?
    Stev

    Limeybrit is correct....the way Sun recommends (and which I use) is a boolean at the top of your runnable code. If false, you simply return and don't hit any of the other code in the runnable method.
    At the end of your run process, you simply set your Thread to null and wait for the garbage collector to clean up.

  • Best way for a thread to wait without busy-waiting

    Hi!
    I have a thread that has nothing to do but to monitor the status of a variable
    public static boolean askToClose. This variable is set by other
    threads to indicate that this thread should stop now. But I don't want the thread
    to busy-wait like in this piece of code :
    public void run() {
         while (!askToClose) {
              Thread.sleep(1000);
         cleanAndStop();     
    }I'm new to Thread programming in Java so I'm not sure what's the best way to wait
    for an event without busy-waiting. I've tried using interruption instead of
    monitoring for the boolean variable :
    public void run() {
         try {
              synchronized (this) {
                   System.out.println("WAITING");
                   wait(0);
         catch (InterruptedException e) {
              System.out.println("INTERRUPTED !");
         cleanAndStop();     
    }and the other threads would simply call myThread.interrupt() instead of setting
    askToClose = true;And I've also used a LinkedBlockingQueue :
    public static LinkedBlockingQueue q = new LinkedBlockingQueue();
    public void run() {
         try {
              q.take();//Waiting
         catch (InterruptedException e) {}
         cleanAndStop();     
    }and on the other threads :
    MyThread.q.add(new Object());Which one is the best solution ? Do I really avoid busy waiting with this code? Is
    there a better way of doing this?
    Thx for your help !

    Your wait() based solution is OK, except that the other thread should
    use
    synchronized()
      notify();
    }

  • Videos emailed from my iPhone4 won't open or play on the recipients' computer.  Is this a quicktime/windows media player issue?   What is the best way to solve this ?  THANKS!

    Videos emailed from my iPhone4 won't open or play on the recipients' computer.  Is this a quicktime/windows media player issue?   What is the best way to solve this ?  THANKS!

    Is the recipient using QuickTime on their PC to view the video?
    What is the error message provided when trying to open/view the video?

  • I own CS4, upgraded to CS5, then joined CS6, CC... and now I installed CC14. Which will be the best way to delete or uninstall the programs I don't need keeping only CC14 without running into issues? I have an Alienware Area 51 PC running Windows 7.

    I own CS4, upgraded to CS5, then joined CS6, CC... and now I installed CC14. Which will be the best way to delete or uninstall the programs I don't need keeping only CC14 without running into issues? I have an Alienware Area 51 PC running Windows 7.

    Which will be the best way to delete or uninstall the programs I don't need keeping only CC14 without running into issues?
    There is none. Whatever you do to get rid of the older versions will inevitably do damage to shared components and other stuff of the new versions as well. That's just how it is with this approach... Uninstall the older versions, run the cleaner tool then reinstall CC 2014.
    Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6
    Mylenium

Maybe you are looking for

  • HP PhotoSmart Premium inkjet printer - model c309a will not always scan or copy

    My HP PhotoSmart Premium injet printer (model C309a) will sometimes not scan a document.  When I press the "Scan" or "Copy" button, the display shows "Scanning" but nothing happens....  Otherwise, the printer seems to work fine. This "will not scan"

  • HT5610 How do I retrieve the stuff I backed up on icloud to my new computer?

    How do I retrieve the stuff I backed up on icloud to my new computer?

  • Cumulative count

    Hi, Is there a way to get the cumulative count of rows ... table a with 2 fields as follows... a) id, stat a123 1 a342 1 s122 2 s222 2 r334 3 e333 4 I want to get the cumulative sum of rows like below... select count(*), stat from a group by stat; th

  • Advantages and disadvantages of touch and non touc...

    Hi, I'm planning to buy Nokia N8 in few days. I heard that there are no more S60 keypad phones in the market. I thought of buying keypad one like N86. So please tell me the advantages and disadvantages of touch and non touch Symbian phones? Thank You

  • Insufficient disk space for encoding?

    Hello, when I burn my DVD in DVDSP I get this message: "Insufficient disk space for encoding. Please free up disk space on your encoding target drive. Build cancelled" I couldn't find anything in the documentation about this. I have 26 GB on my hard