Stop a loop is thread has excpetion

Hi i have a class starting a thread per message obtain from a message queue. If i encounter an exception in a thread how do i stop the class from starting more threads. Code is below and i will explain more after the code.
while (!stopRunning)
      msgText = mqSample.getMessage()     
      if (!no_more_messages)
           MQMover mqThreadClass = new MQMover (msgText,
                                                mqSample.vFields,
                                                mqSample.connMB);
           Thread mqThread = new Thread(mqThreadClass);
           mqThread.start()        
  } This code is the main in a class call MQConnector. I want the tread to send a message to this class to stop firing more threads? Any help do i need to clarify more?

Uh...how about setting no_more_messages to true? Ugly way to use underscores btw...

Similar Messages

  • [svn] 650: Prevent potential NPEs from wait' ed long poll requests whose threads exit after the underlying endpoint has been stopped by a separate thread .

    Revision: 650
    Author: [email protected]
    Date: 2008-02-25 16:55:13 -0800 (Mon, 25 Feb 2008)
    Log Message:
    Prevent potential NPEs from wait'ed long poll requests whose threads exit after the underlying endpoint has been stopped by a separate thread.
    Bugs: BLZ-65 - Long-polling clients trigger NPE on server shutdown.
    QA: Yes
    Doc: No
    Ticket Links:
    http://bugs.adobe.com/jira/browse/BLZ-65
    Modified Paths:
    blazeds/trunk/modules/core/src/java/flex/messaging/endpoints/BasePollingHTTPEndpoint.java

    Hi,
    Looks like you're using BDB, not BDB JE, and this is the BDB JE forum. Could you please repost here?:
    Berkeley DB
    Thanks,
    mark

  • How to stop while loop when a specified function is terminated?

    I want to make a program which has 2 thread, one of which is to control some devices, and the other is to measure outputs of the devices.
    To do that, I should make a 2 independent loops, but there comes a problem here.
    I want to terminate 2 loops at the same time, but it's difficult for me to do that, because when I try to notify upper sequence's termination to lower loop by some value change, they have some dependency.
    That's why I need your help. I want to know how to stop lower loop when the upper sequence's termination keeping their independency.
    Please let me know. Thank you.
    Attachments:
    help.JPG ‏200 KB

    Is the upper loop commanding the lower loop at all?  I would think you would have some type of communication between the loops.  Just use that communication to send a stop command.  Or the next best way is to just simply use a notifier.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

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

  • What is the best way to stop parallel loops at the same time, from any loop?

    If there is a vi with two or more parallel while loops, what would be a good method to simultaneously stop parallel loop execution, from any of the parallel loops? My intent was to try and do this without local variables, so I used notifiers. This seems like an ok method for two loops, but how about for n loops?
    In addition, my code has a flaw. I use an OR block to compare the stop status of each of the loops. This works fine most of the time, but if both loops are triggered to stop at the same time,the boolean result will be false, causing the loops to never stop. How can this be avoided?
    Thanks,
    Curt
    Attachments:
    parallel_loop_w-stop.vi ‏54 KB

    I think you have the right idea, notifiers are one of the better ways to stop parallel loops. You can simplify things by using 1 notifier for everything. I modified your VI to use 1 notifier, it will set the notifier to True ONLY if the loop is stopping, then it stops. The other loop will read the notifier status, and stop based on it the next time it executes.
    I also changed the second loop to stop and notify if it has an error (that is usually a good idea, especally if you have I/O or other things that can cause problems)
    I also changed the switch mechanical action, that will eliminate the problems for your second question.
    The VI's attached are written in Labview 7.0
    P.S. If you have 7.1, the Queues are polymorphic, meaning that the typecast operat
    ions are NOT needed!
    Attachments:
    parallel_loop_w-stop7_0.vi ‏45 KB

  • I have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    i have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    Hi fais,
    Following through with what JB suggested. The steps involved in replacing the inner for loop with a while loop are outlined below.
    You can replace the inner for loop with a while by doing the following.
    1) Right-click of the for loop and select "Repalce" then navigate to the "while loop".
    2) Make sure the tunnels you where indexing on with the for loop are still indexing.
    3) Drop an "array size" node on your diagram. Wire the array that determines the number of iterations your for loop executes into this "array size".
    4) Wire the output of the array size into the new while loop.
    5) Set the condition terminal to "stop if true".
    6)Drop an "OR" gate inside the while loop and wire its output to the while loops condition terminal.
    7) C
    reate a local of the boolean "stop" button, and wire it into one of the inputs of your OR gate. This will allow you to stop the inner loop.
    8) Drop a "less than" node inside the inner while loop.
    9) Wire your iteration count into the bottom input of the "less than".
    10) Wire the count (see step 4 above) into the top input of the less than. This will stop the inner loop when ever the inner loop has processed the last element of your array.
    Provided I have not mixed up my tops and bottoms this should accomplish the replacement.
    I will let others explain how to takle this task using the "case solution".
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to stop while loop for particular time

                    public void test()
                   new Thread(new Runnable()
                        public void run()
                             //Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
                             System.out.println("test");
                             //System.out.println("test ..."+i);
                             try
                                  Thread.sleep(3000);
                             catch (InterruptedException e)
                   }).start();
            public void startTest()
                    while(i < marquee_Str1.length)
                   marLbl1.setValue(marquee_Str1); //set value to textbox for perticular id
                   marLbl2.setValue(marquee_Str2[i]);
                   marLbl3.setValue(marquee_Str3[i]);
                   test(); // call thread function
                   i++;
    in this code while loop don't stop
    plz help me to stop while loop for certain period by using thread or other technique                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Yes.. the original problem would be your test() method put the sleep in an entirely separate thread of execution. So the thread is created then the method just keeps waiting. The while loop should directly call Thread.sleep... which you have apparently figured out!

  • Game main loop using Thread. How to ?

    Hello !
    Is anybody know what happened with threads, which was created by MIDLet when MIDLet will be closed ?
    More details: i design a specific game engine for MIDP2.0. In many available resources main game loop implemented through separate Thread, but one thing is just missed - how to correctly stop this thread when player want to exit from game ? Mostly all examples just call notifyDestroyed() and do nothing more. But I think what it is wrong program behaviour. So I have questions to advanced MIDP programmers:
    1) Do we need correctly stop all Threads before call notifyDestroyed() or can just forget about it ? (I think need to stop all threads ...). Maybe some documentation or usefull link is available about this or related problem ?
    Where get documentation about Threads in Java, and how to VM stop thread during garbage collection. As I think exactly G&#1057; will destroy MEDLet threads if I don't stop it manually ?

    ... But I think that all created threads should be
    killed in logical right place. For example, if thread
    is using for animation and created in Canvas object,
    this thread should be killed before killing Canvas
    object (for example command "Exit" have been choosen,
    firstly we kill thread, secondly we call destroyApp )
    If midlet uses user interface, I never called
    notifyDestroyed() from my own created thread, because
    application usually should be finished when command is
    choosen or some key pressed.I completely agree with both notes, and even think what I was wrong in general - when decide to use main loop paradigm in PC way (strictly speaking I just copy paradigm from PC project). You give me an good idea - use custom-purpose threads instead general-purpose "main-loop" thread. I just will look on this thread from other point of view and use it only for call update() for my canvas and provide way to handle time-depended actions (say for animation). No anything more. So all I will need - proper synchronization when perform time-depended action.
    So I can stop that thread from destroyApp() when AMS want to destroy my MIDlet, and I can stop that thread from any event-handler in my canvas (in command handler or just key-pressing handler) and then call notifyDestroyed() in order to stop MIDLet manually. So no more calling notifyDestroyed() from any MIDlet-own threads. What you think ?
    Just for intresting - citation from JVM Specification:
    2.16.9 Virtual Machine Exit
    A Java Virtual Machine terminates all its activity and exits when one of two things happens:
    * All the threads that are not daemon threads (�2.17) terminate.
    In CLDC specification no any changes in this paragraph was made, so we can say what if we does not stop all threads which we create in MIDlet the MIDLet execution will be endless ? It is intresting - implementation JVM in real device start JVM for each MIDLet or start JVM once and start MIDlets in this one-session JVM ? In first-case it is possible to just stop JVM (with all threads) and release any resources (looks little dirty, but why not ?) in second-case all "zombie" threads can live endless (until device switch off) and just decrease performance and eat resources ...
    Need more specification ...
    Many thanks to RussianDonz for collaboration.

  • Stop Playback Looping During Editing

    Can't seem to find where to set the loop/don't loop option. At the end of the timeline, the playback goes to the beginning and starts playback again. I want it to stop at the end and not loop (during editing). Can you help me find the setting to stop it from continuing playback from the beginning of the clip (stop playback looping during editing).
    Premiere Elements 10
    Win7(64)

    There is no direct way to stop playback AT the last Frame.
    Does the End key not work on your computer?
    Once playback has been stopped, the PageUp and PageDn keys will take you to the first Frame of the last Clip, or to the first Frame of that last Clip. The Cursor keys will also step you, Frame-by-Frame, inside the Clip.
    Good luck,
    Hunt

  • Stopping while loop after last element of 2d array is passed through

    I posted something similar to this before, but what I got didn't work.  So this time I'll try to be more clear with what I am trying to do.  What I have done is combine two 1d arrays into a 2d array, and am using it to run an experiment.  I split the 2d array into a 1d array by column, and am trying to get the while loop that the array is in to stop after  the last element of the array is indexed.  I need to use a while loop because the array is constantly updating because the number of elements can be changed while the program is running.  What I am having trouble with is getting the while loop to stop after the last element has run, because the last element is subject to change.  Any ideas?
    Thanks 

    I am trying to run a measurement using labview to control different instruments.  The program is suppossed tp work in that it runs a measurement for each current setpoint inputed, for 1 magnetic field setpoint.  So for example, if the magnetic field setpoint is 8000 gauss, and the two current setpoints are .00001 amp, and .0001 amp, it will run the meauserement twice for the 2 current setpoints for each magnetic field setpoint.  What I am trying to do is that sometimes, I might have to edit the magnetic field setpoints while the program is running.  I am having trouble with refreshing the magnetic field setpoints, which allows the user to input a new magnetic field setpoint while it is running.

  • After I purchased the creative cloud, I receive an error message when trying to use premier pro cc 2014.  It states "Adobe Premiere Pro 2014.2 has stopped working.  A problem has caused it to stop working.  Windows will close the program and notify you of

    After I purchased the creative cloud, I receive an error message when trying to use premier pro cc 2014.  It states "Adobe Premiere Pro 2014.2 has stopped working.  A problem has caused it to stop working.  Windows will close the program and notify you of a solution."  When I used the trial I never received this message.  Now after purchasing it I receive this error each time I open PP and am unable to use. it.  Any ideas or support to fix this issue?

    What does the detailed crash report say?
    And have you updated your video card drivers from the GPU maker's website? (most crashes on launch are due to bugs in out of date video card drivers)

  • HT1339 ipod not recognized by my computer, it says "Windows has stopped this device because it has reported problems. (Code 43)" please help

    please help...
    my computer is not recognizing my ipod classic gen 5. it shows the sad face then i did the basic troubleshooting until logo comes out...
    still my computer is not recognizing my ipod.. it still says "Windows has stopped this device because it has reported problems. (Code 43)"

    See here: iPod displays a sad iPod icon
    Note that it's often a good sign of a hardware issue with the iPod's hard drive meaning the iPod will need to be serviced or replaced.
    B-rock

  • ITunes keeps shutting down when I open it up.  The message says iTunes has stopped working.  A problem has caused the program to stop working correctly.  Windows will close the program and notify you if a solutions is found.

    iTunes keeps shutting down when I open it up.  The message says iTunes has stopped working.  A problem has caused the program to stop working correctly.  Windows will close the program and notify you if a solutions is found.

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    If you've already tried something like the above then try opening iTunes in safe mode (press and hold down CTRL+SHIFT as you start iTunes) then going to Edit > Preferences > Store and turning off Show iTunes in the Cloud Purchases. You may find that iTunes opens normally now.
    tt2

  • How to find out if a thread has finished execution?

    Hi, Am new to multi-threaded programming. I have a question: I start a new thread from the main thread. This new thread has to update a swing component & thats it. How do I know when the new thread has finished its execution? Also, I need to kill the thread once it finishes its execution?..or will Java's GC take care of it? If I need to kill it from the code, how do I do it? I see that the destry() method of Thread class is deprecated.
    Thanks.

    boolean isAlive()
    Also, I need to kill the thread once it finishes its execution?..No
    or will Java's GC take care of it? Yes
    You can do Thread.join.
    See the API docs and/or a threads primer.

  • My charger just stopped working. The cord has no visible damage and the plug box works fine with other phone cords. I've had my phone

    My charger just stopped working. The cord has no visible damage and the plug box works fine with other phone cords. I've had my phone for less than four months now. Will Apple provide a new charger if theirs is faulty? I have not dropped it in water or anything. It was a normal day and I had 20% battery and I tried to charge my phone and it wouldn't charge. The charging pug box works fine with other phone USB cords so I know its something to do with the charging cord.

    Eklms wrote:
    My charger just stopped working. The cord has no visible damage and the plug box works fine with other phone cords. I've had my phone for less than four months now. Will Apple provide a new charger if theirs is faulty?
    Yes.
    Everything is included in the warranty.

Maybe you are looking for

  • Schedule line : delivery date not changes

    Dear Gurus, When I change delivery date change in delivery documents and sales documents, picking date, pricing date, etc.. changes, but in sales document, schedule line's delivery date does not changes. Please help me to change the same and kindly t

  • Can't import music to new iTunes

    I had a lot of lost music since I upgraded iTunes to 10.1.2 I booted into my backup HD where I had iTunes 10.1.1 and all music played. Went into the Home area into Music/iTunes and copied all music to 4 DVD's Went back into my MAIN HD where I have iT

  • Itunes freezes when syncing

    When i put my ipod on to sync it starts backing up then stops. My ipod says 'sync in progress' but its not syncing properly. Then itunes freezes and wont even open again. please help!!!

  • How do I return to the previous version of Java?

    After the latest Apple Update I have After the latest Apple-Update, I use Java 6 Update 24 for Mac OS X 10.6. If I try to upload the files in Safari and clicking the button for the upload, the window don't open to select the files. If I try the same

  • How to install CS2 when already have CS PS4, 5, LR2 & Reader 9?

    Feb 28, 2010- I had CS2 Premium on my old laptop.  I'd updated to PS 3 and then to PS 4 (standard). Then my LT crashed.  I now have a desktop: Quad processer, 64-bit, 8 GB ram, two hard drives (C: 1 TB and D: 2 TB). I've installed PS 4 & 5, Reader 9