Threads don't stop

Hi all
I have a class that extends Thread it gets to the end of the run method but the thread doesn't want to stop running. I though about using the stop() method, but it's depricated due to the fact that it can cause some problems with the program.
I was wondering whether there is any other way to ensure that the thread stops. I have tried the return statement as the documentation suggest for a replacement to the stop() method.

Is there any GUI business going on in this app?The only GUI business that is going on is the following set of calls just to get user input(in the test-app)
        JOptionPane.showMessageDialog(null, "Please specify the directory");
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        response = fileChooser.showOpenDialog(null);
If you want the app to end when that thread is done,
then the simplest thing is to just have main join that
thread and then call System.exit(0) after the join.
That's not always the safest route though. If the
program is still running, it suggests there are other
non-daemon threads still alive. In this case, they're
presumably done with their work and just waiting for
more. If so, then System.exit should be safe.The test-app should end when the thread is finished but when It gets imlemented into the live app, the live-app needs to be able to continue. This thread will be called multiple times at a regular interval during the life-time of the app. The live-app is a server app, thus it can go on indefinitely, and I don't need to have threads that don't stop running when they aren't required.

Similar Messages

  • Satellite M30X: fans don't stop if connected to the power supply

    hi ,
    I have a M30X and during the last months the fans when I'm connected to the power supply don't stop at all. It also shut down quite often. However the laptop is not warm. Do you have any clue?
    Regards,
    armando

    Hi
    If you connect the AC adaptor to the notebook the Toshiba power saver changes the power modes. Possibly the power mode has different settings in the ??basic setup??. Please check the cooling method and change it to lower level.
    But of course, the dust and debris could have a bad influence on the fan behavior.

  • Videos Played through Home Sharing Don't Stop

    Since the last update, videos that we play on an iPad over the Home Share network, don't stop playing when you shut down the app (the sounds keeps going and the Play symbol is still showing in the top right corner).  Sometimes, the controls to stopt he video do not come up at all while a video is playing.
    Anyone else having a problem like this?  Happening on both of our iPads (iPad 2 and iPad 3).
    Thanks.

    Forum is designed to address technical problems. You can get free advise here, or you can contact apple
    for the advice. You may have to pay to Applecare for the support thou. At that time I do not have precise information on how to stop that from happening, what I would try is going to settings, general, reset and use reset all settings option. You will lose your wallpaper, and will have to reenter wi fi password, but will not lose any other info. You also will have to go through initial set up where you have to pick English and your country. You want to make sure that you set your ipad as new, when presented with that option.

  • I am trying to make a time lapse video with Premier Element 13. When trying to publish it at about 15% of work done it stops and in a new screen it says an unknown error, what am I doing wrong?

    I am trying to make a time lapse video with Premier Element 13. When trying to publish it at about 15% of work done it stops and in a new screen it says an unknown error, what am I doing wrong?

    Click on the blue Internet Recovery in nbar's post. That is a link to what computers can run Internet Recovery.
    Do a backup,  preferable 2 separate ones on 2 drives. Boot to the Recovery Volume (command - R on a restart or hold down the option/alt key during a restart and select Recovery Volume). Run Disk Utility Verify/Repair and Repair Permissions until you get no errors.  Reformat the drive using Disk Utility/Erase Mac OS Extended (Journaled), then click the Option button and select GUID. Then re-install the OS.
    OS X Recovery
    OS X Recovery (2)
    When you reboot, use Setup Assistant to restore your data.

  • I have several times tried to stop following a thread in the PDF's forum about security issues and i still keep getting flooded with emails from this thread. I used the action within the thread that says stop following but appears to have no effect I stil

    I have several times tried to stop following a thread in the PDF's forum about security issues and i still keep getting flooded with  emails from this thread. I used the action within the thread that says stop following but appears to have no effect I still keep  getting from 5 to 20 emails daily. Please help!!!!!!!

    This may be helpful: How do I disable email notifications?

  • Upload of iTunes library on iCloud don't stop and the new songs not on icloud ? help (mac user)

    the upload from my library on iclous don't stop... hours and hours, and the new songs not on icloud ? why ?

    Welcome to the Apple Community.
    Hours and hours is not all that uncommon for large libraries, how large is yours.

  • JMF threads can not stop?

    My program is designed for two-way audio conference, but now I met a problem that there are some threads can not stop before I start some calls(maybe 100 times).How can I release this threads? please help me, thank you in advanced.
    RTPEventHandler
    JMF thread: com.sun.media.ProcessEngine@6b9fee[ com.sun.media.ProcessEngine@6b9fee ] ( configureThread)
    JMF thread: SendEventQueue: com.sun.media.processor.unknown.Handler
    JMF thread: SendEventQueue: com.sun.media.ProcessEngine
    JMF thread: com.sun.media.processor.unknown.Handler@1ca8dc7[ com.sun.media.processor.unknown.Handler@1ca8dc7 ] ( configureThread)
    JMF thread: com.sun.media.ProcessEngine@e1d29e[ com.sun.media.ProcessEngine@e1d29e ] ( configureThread)

    Hi TGreybeard,
    Have you looked at the [[Firefox keeps opening many tabs or windows]] Knowledge Base article? There is some good information in there that should help you resolve the issue.
    Hopefully this helps!

  • The touch don't "stop working" while I'm in a phone call

    Every time I call to someone the touch don't stop then I stay disconnect or placing in the dumb without wanting! I bought this iPhone a week ago! Can I fix this problem by myself or I will need to take it to a apple store?

    DO you have a case on it?
    IF so, remove it and see if that solves the issue.

  • My Torch don't stop rebooting

    I have installed adidas miCoach from App World, after the installation I set authorization. After that my Torch shut down an reboot and don't stop to reboot again and again on the first screen. The black one. How can I fix that ?
    Solved!
    Go to Solution.

    also can boot into safe mode
    How to start a BlackBerry smartphone in safe mode
    Click here to Backup the data on your BlackBerry Device! It's important, and FREE!
    Click "Accept as Solution" if your problem is solved. To give thanks, click thumbs up
    Click to search the Knowledge Base at BTSC and click to Read The Fabulous Manuals
    BESAdmin's, please make a signature with your BES environment info.
    SIM Free BlackBerry Unlocking FAQ
    Follow me on Twitter @knottyrope
    Want to thank me? Buy my KnottyRope App here
    BES 12 and BES 5.0.4 with Exchange 2010 and SQL 2012 Hyper V

  • Thread: how to stop it?

    I'm new with thread and I don't understand some things about that.
    For example: when I create a Class that extends Thread class I must override the method run(), right? After when I call the method start() from the Class the thread runs in a never-ending cycle? How can I stop it?
    The example code:
    public class MyClass extends Thread {
        private int value;
        public MyClass() {
            value = 0;
        public void run() {
            value++;
    }Does the class continue to do the addition until it will throw an exception (when the max value of int type is reached)?
    Message was edited by:
    Lukyan

    Try to run it and see, no?Quoting myself ... I did not mean to be facetious. I really thought that actually running the code would be the clearest way of "seeing" the results. Better answers both before and after mine have provoked me to add the following:
    It is very common to code the actual guts of your "Thread" similar to this:
    private boolean run = true;
    public void run() {
      try {
        while (run) {
          doMethodA();
          doMethodB();
      } catch(InterruptedException ie) {
        doMethodC(); // or print the stack trace or something
    private void doMethodA() {
    private void doMethodB() {
      if ( "bad".equals(condition) )
        run = false;
    }

  • A thread wouldn't stop

    Hi
    Can anyone explain me this:
    I have a thread running.
    (A class ext. Thread impl. Runnable)
    I wouldn't be able to stop the thread outside with doing:
    mythread = null;
    The thread would stop if I do:
    mythread.stop();
    Although, the compiler says that this method is deprecated.
    How should I stop the thread then?

    Btw, did you say you have a class that both extends Thread and implements Runnable? There is no reason to do that.
    If you extend from Thread, then you start the thread by calling start() on an instance of that object.
    If you implement Runnable, then you create a new Thread object and start this object:
    Runnable target = new MyRunnable();
    Thread thread = new Thread(target);
    thread.start();

  • Safari restrictions don't stop images from being seen

    When I enable restrictions on my child's iphone for Safari and only certain websites are allowed, my child can still search a subject and then hit images and it will pull up images.  Completely defeats the purpose.  If I don't want my child reading about a certain topic, I definitely do not want them to see the topic.

    If you dock the panels on the right (layers,etc) like the toolbox is docked that will stop the image from going under the panels.
    Just grab the top of the panels (red box in screenshot) and move to the right until you see a blue line, then release.
    MTSTUNER

  • 'Laserjet 1022n Windows Update' causing printing problems: print jobs don't stop printing

    Hello,
    a few days ago, I installed the Laserjet 1022n Windows Update on my Windows 7 64 bits and since then, I can't print a page normally: the page doesn't stop printing. I am using a network port with TCP/IP.
    I made several trials to solve this problem:
    - uninstall the printer driver and installing it again (I tried the last version on the HP site and an older one that worked perfectly before)
    - update the firmware of the printer to the last version on the HP site.
    When I pause the printer and start the print job, you see it arriving in the list. Resuming the printer, the print starts on the printer but you see that the job stays in the list, flashing again and again. The printer keeps printing the same page.
    I don't know what I can do to solve this problem. There is no mean of uninstalling the HP Laserjet 1022n software update because it doesn't appear in the list of installed programs (well on the list of the done updates by the way op windows updates).
    I have the same problem printing on the same printer from another Windows  7 PC (with the same windows update done)
    But I have no problem printing with my laptop on another network printers.
    Is there someone having the same problem and how to solve it ?
    Thanks for answering
    This question was solved.
    View Solution.

    I found the solution on this site : http://www.tomshardware.co.uk/forum/59912-29-1022n-printer-stop-printing
    You just have to uncheck the chekbox "Enable two-way communication" on the "Ports" tab of the printer properties and it works normally again !!!!

  • Trying to verify my account but the verify threads don't have a reply option or instructions

    What am I doing wrong?

    Thanks, for a normal user who gets into these forums by searching on problem terms this is really convoluted because the stickies don't appear and I went through at least 10 threads of the verify your account posts that were all expired. For me as a normal
    user who are searching and not browsing, stickies DON'T  automatically appear, I looked because some threads referred to them and I couldn't see em.
    Also many of those earlier threads are still what show up first on google searches, not the more recent ones that have the link to the sticky (although some middle aged ones have both a link to a thread that is expired followed by another link to a sticky
    that might still be good).
    I'm sure this all has been written about a thousand times somewhere in threads 1-26.
    Hoping a better solution is found.

  • Javafx Multi Threading - How to stop a thread

    Hi,
    I'm working on a Javafx and Java based chat client. To avoid GUI freezing I have put all "business logic" calls to Java using the Runnable feature. Everyting works ok, but when for example disconnecting the chat client I would also like to stop this specifc thread, avoid building up unused threads. I have tried using .stop() but it looks like its being ignored.
    Here my code:
    main.fx:
    progressIndicator.visible = true;
            var listener = FXListener_interface_connection {
                        override function callback(errorCode, errorMessage): Void {
                            //do something
                            if (errorCode != 200) {
                                setIcn(errorMessage);
                            } else {
                                progressIndicator.visible = false;
                                imageView9.visible = true;
                                openMessageListener();
                                rosterListener();
                                var ooo = ScaleTransition {
                                            duration: 0.2s
                                            node: imageView9
                                            byX: 0.6 byY: 0.6
                                            repeatCount: 8 autoReverse: true
                                ooo.play();
            var connect = FXListener_connection {
                        listener: listener
                connect.start();listener_connection.fx:
    public class FXListener_connection extends JavaTaskBase {
        public var listener: FXListener_interface_connection;
        protected override function create() : RunnableFuture {
            new Java_callback_connection(listener);
    }connection_interface.java
    public interface FXListener_interface_connection {
        public void callback(Integer errorCode, String errorMessage);
    }connection_callback.java
    public class Java_callback_connection implements RunnableFuture {
        private static FXListener_interface_connection listener_interface_connection;
        public Java_callback_connection(FXListener_interface_connection listener_interface_connection) {
            this.listener_interface_connection = listener_interface_connection;
        @Override
        public void run() throws Exception {
            //call function xmpp_connect()
            static_variables.xmpp.xmpp_connect();
        public static void connection(final Integer errorCode, final String errorMessage) {
            Entry.deferAction(new Runnable() {
                @Override
                public void run() {
                    listener_interface_connection.callback(errorCode, errorMessage);
    }

    jdevel doesn't let me debug;
    public class ProgressBarModel extends BoundedRangeModel {
    BooleanValueWrapper stopFlag = new BooleanValueWrapper(false);
    BooleanValueWrapper stopFlag2 = new BooleanValueWrapper(false);
    IntValueWrapper value = new IntValueWrapper(0);
    Thread newProgress = null;
    Thread newProcessFile = null;
    public void start(ActionEvent e) {
    value.setValue(0);
    stopFlag.setValue(false);
    ProgressSimulator progressSimulator = new ProgressSimulator();
    newProgress = new Thread(progressSumulator);
    newProgress.start();
    ProcessFileThreadMe processFileThreadMe = new ProcessFileThreadMe();
    newProcessFile = new Thread(processFileThreadMe);
    newProcessFile.start();
    class ProgressUpdater implements Runnable
    public void run(){
    try
    System.out.println(" ProgressUpdater is running");
    //stop fag is true if it is set to true or if value is equals or greater
    //than maximum
    try { 
    stopFlag.setValue(stopFlag.getValue() == true? true : (value.getValue() < maximum? false:true));
    //run in loop until stop condition is met. Make sure system doesn't
    //fail if values are initially set to the same value
    while (!stopFlag.getValue() && value.getValue() != maximum) {
    newProgress.interrupt();
    newProgress = null;
    } catch(Exception e) {
    stopFlag.setValue(true);
    stopFlag2.setValue(true);
    class ProcessFileThreadMe implements Runnable
    public void run(){
    System.out.println(" ProcessFileThreadMe is running");
    try
    if(stopFlag2.getValue() == true) {
    // interrupt this thread
    // set it to null
    return;
    bean.persisit(value, stopFlag);
    newProcessFile.interrupt();
    newProcessFile = null;
    catch (Exception exc)
    stopFlag.setValue(true);
    stopFlag2.setValue(true);
    exc.printStackTrace();
    In the bean the v alue is incremented
    Edited by: user597294 on Jul 21, 2011 6:33 AM

Maybe you are looking for

  • HT201210 my phone will not restore

    I HAVE BOUGHT S/HAND IPHONE BUT WILL NOT RESTORE FROM MY BACKUUP /HELP

  • Recover deleted video from iphoto

    hi i accidentally deleted my recorded videos from iphoto on macbook pro , then i changed the os version from snow leopard to mountain lion , can anyone help me with the procedure of recovering the deleted videos.. they are emotional and personal mome

  • User Decision & Form

    With a requirement, it is required to display a lot of information in the 'User Decision' ( in the area of Task Description). This means, this description will have to be displayed to help the user know the information about the document which he wil

  • Can I join a trailer and iPhoto slideshow?

    I am trying to do a dvd of my granddaughter.  There are aroud 500 pictures.  I'm trying to do a slideshow in IPHOTO.  I've already done a trailer in IMOVIE.  Can I join the two?

  • I can't download mountain lion.

    I've got a mid 2007 24", ive been to the app store and paid and the icon just sits in the dock and says "Waiting". Its been a couple of hours now. Othe machines in the house are working fine. Any suggestions?