How to "kill" AWT Event Queue thread without using System.exit()?

When I run my program and the first GUI window is displayed a new thread is created - "AWT-Event Queue". When my program finishes, this thread stays alive and I think it causes some problems I have experienced lately.
Is there any possibility to "kill" this thread without using System.exit() (I can't use it for some specific reasons)

All threads are kept alive by the JVM session. When you use System.exit(int) you kill the current session, thus killing all threads. I'm not sure, though...
What you could do, to make sure all threads die, is to make ever thread you start member of a thread group. When you want to exit you app, you kill all the threads in the thread group before exit.
A small example:
//Should be declared somewhere
static ThreadGroup threadGroup = new ThreadGroup("My ThreadGroup");
class MyClass extends Thread {
super(threadGroup, "MyThread");
Thread thread = new Thread(threadGroup, "MySecondThread");
void exit() {
//Deprecated, seek alternative
threadGroup.stop();
System.exit(0);
}

Similar Messages

  • Closing a JFrame without using System.exit(0)

    Hello all,
    I'm writting an application at the moment that uses a JFrame as an "about box" invoked when a menu item from another JFrame is selected . The about box is set to undecorated, and I have set up an Thread to handle an animation of the credits that move up slowly. I have also added into it code to play a sound file while the credits are running.
    I wanted to have it so that the user can just click once anywhere on the Panel area of the about box, and that would close the about box window and stop the sound.
    I can get it to stop the sound on click no problem, what I'm having issues with is closing just the about box Frame. I've used System.exit(0) but this closes the original application, which I dont want it to do. I've been looking at online example code and I've found that dispose() might work... Problem is my JFrame for the about box is initiated in the main applications JFrame under an eventListener for the menuItem 'about'. The sound file is played inside the JPanel of the about box. And the listener to close it is located in the same place ( about box JPanel ).. does anyone know how to get this frame ( initiated in main applications JFrame ) and dispose of this frame through code located in the JPanel of the about box.
    I hope this is descriptive enough for you.
    Please let me know if you have any questions about my question.
    Many thanks,
    Mark.

    It seems you are asking how to find the parent frame of a Component that you know is within a frame?
    You can getParent() of the component. If it is a frame (instanceof) - dispose, else check for the getParent()...
    If you don't want to code it yourself use SwingUtilities.getWindowAncestor(Component) to get the Window in which the panel is.
    HTH
    Mike

  • How to wait for events to happen without using sleeps.

    hi,
    I am basically doing Thread.sleep() for waiting the events to complete.
    For example, when i click on query button, it takes sometime to process in the background & then populate the data in my table.
    So i am using the sleep method for this event to finish.
    I feel this is not the correct approach, can anyone suggest just me a way to wait for the event to finish without actually using sleep method.
    Thanks & Regards,
    Vishal

    Hi,
    Firstly thanks for your valuable suggestion. But i would like to mention one thing, actually i am using JFCunit framework for doing Unit Testing for our Swing based client. So here i am not looking into Swing code that is being developed but rather i am concentrating on writing unit tests to whatever that is been developed.
    So when i click on the query button automatically, it is taking sometime to process (few seconds) & then its populating the data in a table. So in this case if i have to use the progress bar for the event to finish, i guess i have to modify the source code which is not advisable when you are doing unit testing. So i would appreciate if there is any other alternative that you could suggest me apart from using the progress bar.
    Thanks & Regards,
    Vishal

  • Note:304522.1 How to Move Queue Tables without using export import

    Trying to use the pkg available in Metalink "Note:304522.1 How to Move Queue Tables without using export import"
    Using the 10.1.0.x and upwards Package, I'm getting the following error on a single consumer queue table with an xmltype payload:
    SQL> exec move_aqt.move('XFORM_TEST_INT','INTERFACE_XML_QUEUE','SMALLBLOCK');
    BEGIN move_aqt.move('XFORM_TEST_INT','INTERFACE_XML_QUEUE','SMALLBLOCK'); END;
    ERROR at line 1:
    ORA-20000: ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at "SYS.MOVE_AQT", line 652
    ORA-06512: at line 1
    We've tried in multiple environments, always with the same results.
    Trace file shows:
    *** 2006-11-08 10:06:47.154
    *** SERVICE NAME:(SYS$USERS) 2006-11-08 10:06:47.147
    *** SESSION ID:(379.954) 2006-11-08 10:06:47.147
    qtable move procedure starting execution at 08-11-2006 10:06:47 for queue table XFORM_TEST_INT.INTERFACE_XML_QUEUE
    qtable move procedure experienced an exception at 08-11-2006 10:06:47
    qtable move error message ORA-06502: PL/SQL: numeric or value error
    qtable move procedure ended execution at 08-11-2006 10:06:47
    Can anyone help with this? Has anyone used this before successfully (or not successfully). We urgently need this working today to test moving our queue table into a tablespace with a smaller block size for performance reasons in production.
    Thanks for the help!
    Tony

    Thank you,
    Yes we've done that. They've confirmed a problem with the links/scripts on the note. The 10.1 and up version was not really 10.1 and up.
    As they would not have a new version available in time for the move we needed to perform, we switched our approach to using dbms_redefinition instead.
    Thanks for the reply,
    Tony

  • How to extract the mouse cursor image without using JNI

    I want to get the image of the mouse cursor of the system using java. The Robot class captures the screen only, but the mouse icon image is not the part of the screen, so it is not easily detected. But we can get the mouse cursor position using API, but how to get the exact image icon, without using JNI. I don't want to generate my own cursor at that position.

    I am building a Remote Desktop kinda app using java..... I want the screen of the remote comp to be viewed on my screen and generate events from my machine to the remote machine. So, I am capturing the screen images of the remote machine. But the cursor is not part of the screen object. i want to extract the cursor image icon from the remote machine to my machine and render the image.

  • How do I remove an iCloud account without using password?

    How do I remove an iCloud account without using password?

    There is no way if Find my iPhone is turned on. You must know the Apple ID and password. This is Activation Lock, an antitheft feature of iOS 7. See: http://support.apple.com/kb/HT5818

  • My iPhone has two computers in (iTunes wifi sync), how can I remove one of them without using it ?

    Hello everyone.
    My iPhone has two computers in (iTunes wifi sync) how can I remove one of them without using that computer?
    because that PC stopped working so I had to recover it. Now everything is gone on that PC.
    Also I bought a new computer (MacBook Pro) and I use iTunes on it in the mean time. Now I want to remove the old computer!
    here is a photo of my (iTunes WiFi sync)
    is there any way that I can use to do that?
    Thanks

    Hello,
    Did you ever find a solution for this ?
    I have the same issue and i dont know how to fix it.

  • How to download youtube videos to ipad without using a computer.

    How to download youtube videos to ipad without using a computer???  Looking to download some videos people created using Dr. Jean music.  My kid used Dr. Jean in preschool and wanted to keep singing them at home.
    Looking for a friend that doesn't use a computer.  I myself have downloaded some kids educational stuff and added to itunes and then put on ipod/ipad using firefox. 
    Is there an easy way, so they don't go to the photo roll??
    thanks in advance.

    There are some Apps you can use, but be careful they will only download these videos inside the App, so you won't ba able to play them in your video app or share them.
    Most popular is the app called "Video Download" but there are a lot of alternatives for free and even with more quality which you can pay for.

  • How can i create an apple id without using a visa or credit card

    how can i create an apple id without using a visa or credit card

    Follow the directions here, EXACTLY:
    http://support.apple.com/kb/ht2534

  • How can I create a new entry without using LOV for foreign keys.

    Referring to TUHRA sample application based on HR database schema. JDeveloper 10.1.3.0.4
    How can I create a new employee without using LOV for the foreign key "job_id".
    On the first page I would like to choose the job_title from adf read-only table.
    After clicking on the "create new employee button" a creation form appears in which the job_id field is set with previous selection.
    Regards M.Winkler
    Edited by: user3541283 on 06.10.2008 03:44
    Edited by: user3541283 on 06.10.2008 03:50

    Hi,
    usually the foreign key is only set if the VO you select is dependent from a master. If e.g. you have DepartmentsVO1 that has an EmployeeVO3 as its nested VO, then creating a new instance of employees automatically add the foreign key. If you add EmployeesVO1, which is not dependent to DepartmensVO1, then the foreign key is not set. So if this is the case in THURA (keep in mind that this is not an Oracle demo but a sample used in a book about ADF) then all you need is to take the independent VO when building the new employee form.
    Frank

  • How to create an instance for RemoteSession without using create() method

    How to create an instance for RemoteSession without using create() method?

    What's RemoteSession? Not in the JDK. And does the question have anything to do with concurrency?

  • How to update and insert the records without using Table_comparison and Map_operation?

    How to update and insert the records without using Table_comparison and Map_operation?

    Use either join or MERGE see this Inserting, Updating, and Deleting Data by Using MERGE

  • How to call session directly in bdc without using SM35

    how to call session directly in bdc without using SM35

    HI
    good
    you r using the sm35 to see the session for calling teh session in your report
    ATA:   messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE ,
    c_session  LIKE   apqi-groupid VALUE 'Z3PL_CUST' ,
    c_job      LIKE   tbtcjob-jobname VALUE 'Z3PL_JOB_CUST' ,
    c_flag     TYPE    c VALUE 'X'  ,
    g_qid      TYPE apqi-qid      .
    thanks
    mrutyun

  • My macbook froze up. Finger gestures work, but I cant close out of any windows. How do I close out the windows without using the track pad?

    My macbook froze up. Finger gestures work, but I can't close out of any windows by clicking on the red "X". How do I close out the windows without using the track pad?

    Command + W will close a window. Command + Q will quit a program.

  • How fast text search field in Oracle without using Intermedia?

    How fast text search field in Oracle without using Intermedia? Thank you, Paul.

    yes,it is overriden in VOImpl
    public void executeQuery()
            setQuery((new StringBuilder()).append(selectStmt).append(" order by ").append(getOrderByClause()).toString());
            OAApplicationModuleImpl oaapplicationmoduleimpl = (OAApplicationModuleImpl)getApplicationModule();
            OAApplicationModuleImpl _tmp = oaapplicationmoduleimpl;
            if(oaapplicationmoduleimpl.isLoggingEnabled(1))
                OAApplicationModuleImpl _tmp1 = oaapplicationmoduleimpl;
                oaapplicationmoduleimpl.writeDiagnostics((new StringBuilder()).append(getClass().getName()).append(".executeQuery").toString(), (new StringBuilder()).append(" Query:").append(getQuery()).toString(), 1);
            super.executeQuery();
    But I have extended VO and substituted the VO . In the substituted VOImpl, instead of executeQuery(),I have written
    public void customExecuteQuery()
              setQuery((new StringBuilder()).append(selectStmt).append(" order by ").append(getOrderByClause()).toString());
              executeQuery();
    Will this work,or do I need to do any changes?
    Thanks,

Maybe you are looking for

  • Problem about installing DB 10.2.0.1.0 on Solaris 10 (×86-64)

    1.How to set kernel parameters with Solaris 10 (×86-64) for installing DB 10.2.0.1.0? When I run the OUI, there are errors after product-specific prerequisite checking: Checking kernel parameters Checking for BIT_SIZE=64; found BIT_SIZE=64.     Passe

  • Why do we need downcasting in Java? What is the use of it?

    Why do we need downcasting in Java? What is the use of it?

  • Policy domain doesn't protected

    I have following problems: 1.I haven't protection for any created policy domain, I have only protection for default policy domains /access and /identity . It can protect requested policy domain, if I put my resources under policy domains . /access or

  • My G5 goes to sleep when proccessing

    Does anyone have a problem with there G5 going to sleep in the following situations, while running iDVD, while running Adobe DNG converter, creating a quicktime movie from imovie, anything that seems particularly proccessor intensive and it just goes

  • Trying to update elements 9 to cs5?

    I apologise if this is in the wrong place but... I've got a copy of Photoshop Elements 9 and was hoping to upgrade to CS5, but in the drop down menu there isn't an option for Elements 9 - only versions 4 to 8. Was I stupid in assuming it can be upgra