How to stop a thread at the end of another

hello
I want to run two threads. They start at the same time, and I want one of them to end when the first one finishes.
I have a main class, a GUI. When I click on a button, it processes an action( first thread), and since this action takes some time, I decided to create a second thread that is a GUI that is a dialog box that says that it is being processed...
So my dialog bow has to disappear when the process ends.
I've already tried this:
boolean stop = false;
Connect connect = new Connect(this);
connect.start();
LdapSearch searching = new LdapSearch();
searching.start();
while( connect.isAlive() ){
     if( !connect.isAlive() ){
          stop = true;
if( stop == true ){
                       searching.interrupt();
}but unfortunately the text written on my dialog box disappears....
does anyone knows how I can make a thread stop at the end of another properly?
thanks for your help!!
Philippe

sorry the code i tried is:
boolean stop = false;
Connect connect = new Connect(this);
connect.start();
LdapSearch searching = new LdapSearch();
searching.start();
while( stop == false ){
     if( !connect.isAlive() ){
          stop = true;
if( stop == true ){
     searching.interrupt();
}

Similar Messages

  • How to stop a thread without the deprecated Thread.stop() method?

    Hi,
    I am writting a server application that launches threads, but the run() implementation of these threads are not written by me (i.e. i have no control over them): they are third-party programs. That's why i could not use the well known Java tutorial way to stop a thread (i.e. with a global variable that indicates the thread state).
    I would like my server to be able to stop these threads at any time, but without using the deprecated Thread.stop() method.
    Any ideas ?
    Thanks in advance,
    Fabien

    Thanks Pandava!
    I was arrived at the same conclusion... As to me, it is a very bad issue, because it means for example that a servlet server can not stop any servlet it launches (especially for preventing infinite loops).
    If i want to be strictly JDK 1.4 compliant, i should not use Thread.stop(). But if i don't use it, i don't have any ideas of how stop a thread that i don't control...

  • I rented a movie on iTunes and, really annoyingly, it has stopped 30 minutes before the end. Any suggestions? And how do I go about getting a refund?

    I rented a movie on iTunes and, really annoyingly, it has stopped 30 minutes before the end. Any suggestions? And how do I go about getting a refund? Thanks so much for any suggestions.

    Hi alefiya,
    Welcome to the Support Communities!  It sounds like the movie didn't completely download. This link will get you in contact with the iTunes Support Team.  They will be able to review your account with you:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBookstore purchase
    http://support.apple.com/kb/HT1933?viewlocale=en_US
    Cheers,
    - Judy

  • When recording voiceovers, I click the stop recording button at the end, but I can't figure out how to get rid of the "click" sound before I send off the recording!

    When recording voiceovers, I click the stop recording button at the end, but I can't figure out how to get rid of the "click" sound before I send off the recording!

    njordan wrote:
    I can't figure out how to get rid of the "click" sound before I send off the recording!
    drag the BottomRight edge of the region to the left, past the unwanted sound

  • My film has not totally downloaded, I did not realise this until it stopped 15 minutes before the end, how do I know when the rented film I have purchased has been fully downloaded. Can I retrieve anyhow

    My film I rented has not fully downloaded I only realised that when it stopped 15 minutes before the end , how do I know when a film has been fully downloaded. Oi would not have thought the film would not have started unless the film was fully downloaded. The film warned me prior to tarting that I only had 48 hours to watch once starting!

    I'm sorry but this is too funny to pass up. 

  • How to stop main thread ?

    Hi,
    Inside my java class, after I launch a GUI, I want to stop this main thread. After user make some choice and close GUI window, then, I want to go back to main thread. I use wait() method inside my class to stop main thread , but it does not work and it give me "IllegalMonitorStateException" error. I met same thing, when user close the GUI window and call method notifyAll(). How to stop main thread for a while and how to go back?? Thanks
    Gary

    Hi,
    you can create a boolean, and create a while loop, with a Thread.sleep(time); when you want to continue, you just have to change the state of your boolean. So you don't hava to exit the main. And you can't restart a run() in a thread. You can run it only once, so try to keep in your run() with an appropriate loop.
    Hope it helps.
    S�bastien

  • How to draw horizontal line at the end of table for multiple line items

    Dear Experts,
                       Pls can anyone help me how to draw horizontal line at the end of table for multiple line items . kindly help me regarding this
    Thanks
    Ramesh Manoharan

    Hi
       I tried as per your logic but it is not solving my problem .  when i am gone to table painter it is showing line type 1 and line type 2
      is below format.. if u see here line type 1 bottom line and line type 2 top line both are same..  so how to avoid this ?
                              line type 1
                             line type 2

  • How do I justify text at the end of a column

    How do I justify text at the end of a column In Pages?
    Also, is there any way to sort a document (alphabetically by the first word of each paragraph) that is not in a table?

    RTPLaw writes:
    How do I justify text at
    the end of a column In
    P    a    g    e    s     ?
    Also, is there any way
    to   sort  a  document
    (alphabetically by the
    first   word   of   each
    paragraph) that is not
    in         a         table?
    No. Like Peter and Walt, I wonder why you'd want to, considering the appearance of such manipulation, illustrated above. Is this a requirement for some specific type of document?
    Regarding your second question, there's no way to do this using Pages as it comes out-of-the-box (or in the downloaded edition). But you can sort the paragraphs of a document alphabetically using WordService, freeware from Devon Technologies. The link will take you to their download page. Scroll down to the Freeware section and the download link for WordService.
    Regards,
    Barry

  • HT1725 my movie download stops abruptly 20min before the end

    my movie download stops abruptly 20min before the end although the internet connection hasnt been interrupted.
    I get the error message: there was a problem downloading "le gamin au velo". An unknown error occurred (-50). Please check network connection." Have you seen this error before? Thanks

    Perhaps try the "Error -50," "-5000," "8003," "8008," or "-42023" section in the Specific Conditions and Alert Messages: (Mac OS X / Windows) section of the following document:
    iTunes: Advanced iTunes Store troubleshooting

  • How to get each thread in the threadpool

    Hi,everyone.I'm now learning java.util.concurrent package and I have two questions about the threadpool.
    1) How to get each thread in the threadpool;
    2) How to get each thread's data in the threadpool and dispaly them onto GUI;
    e.g :
    There are 5 threads in the threadpool(ThreadPoolExecutor) and I have 100 tasks(Runnable or Callable),every task scans a directory(every task scans a different directory),how can I display the "real-time" count of the files in the directory which the current 5 threads in the threadpool scan onto the ListView Items in the GUI?

    Willings wrote:
    Hi,everyone.I'm now learning java.util.concurrent package and I have two questions about the threadpool.
    1) How to get each thread in the threadpool;You don't
    2) How to get each thread's data in the threadpool and dispaly them onto GUI;
    e.g : You don't
    There are 5 threads in the threadpool(ThreadPoolExecutor) and I have 100 tasks(Runnable or Callable),every task scans a directory(every task scans a different directory),how can I display the "real-time" count of the files in the directory which the current 5 threads in the threadpool scan onto the ListView Items in the GUI?You should notify your "monitor" when you add something to the pool, and the Runnable/Callable should notify the same "monitor" when it starts to execute, and during its processing. Finally you notify the monitor when the execution has completed.
    Kaj

  • How to stop mail from recovering the same message over and over again to the extent that it has wiped out all start up disk memory?

    How to stop mail from recovering the same message over and over again to the extent that it has wiped out all start up disk memory?

    You need to find and delete (move to the Trash) the offline mail cache (.offline cache.) It's a hidden folder (files and folders with a preceding dot are hidden) inside the Mail folder (inside IMAP) in your user library. Since it's hidden, in order to see it run the following command in Terminal in Applications>Utilities. Hit return/enter once you have pasted in the command.
    defaults write com.apple.finder AppleShowAllFiles -bool true ; killall Finder
    To reverse this and hide all those hidden files and folders again
    defaults write com.apple.finder AppleShowAllFiles -bool false ; killall Finder
    Leave hidden files/folders enabled until you finish emptying the Trash so you know it's gone.

  • How to start a thread after the execution/termination of another thread.???

    Hello,
    How to start a thread after the execution/termination of another thread....???
    For example:
    consider two threads: ThreadA and ThreadB
    I could start the ThreadB after the execution of ThreadA.
    How to identify the termination of one thread.....???
    Please help me...
    Thanks & Regards,
    Kayalvizhi

    What do you mean with "it doesn't work"? Do you get a compiler error? Do you get an exception at runtime? What's the error message?
    Jesper

  • Is there a command to sync the end of a region to the playhead or the end of another region?

    Is there a command to sync the end of a region to the playhead or the end of another region?

    For youtube the code would be something like this:
    view-source:calkaweb.herobo.com/video.html
    for HTML5 videos for youtube replace &version=3 with &html5=1 in the youtube URL
    I have no idea how to impletent the youtube code into Edge tho other than an iframe but that wouldn't work I've tried :
    http://forums.adobe.com/thread/1285212
    You would need to place all of the youtube codes into edge in order for it to work but I duno how to do that and no1 answered the question in the thread I made about it.
    as for MP4/HTML5 video you can use
    var video = document.getElementsByTagName('video')[0];
        video.onended = function(e) {
          /*Do Something*/

  • How to  Export/Import "report for the query" to another company

    Hello,
    I do this:
    1.create query in SQL analizer
    2.copy paste into SBO query generator and save
    3.create report for the query
    Then, How to Export/Import "report for the query" to another company ?
    Thanks for your HELP.

    Look for SAP Note number 600813
    That's the note Adele means, I guess.
    <b>Edit (@13:18)</b>
    The direct link:
    https://websmp101.sap-ag.de/~sapidb/012006153200000183292003E.ITF
    ---- Replace *SOURCE* with the source database name.
    ---- Replace *DEST* with the destination database name.
    insert into [*DEST*].[dbo].[RDOC]
    select [*SOURCE*].[dbo].[RDOC].*
    from
    [*SOURCE*].[dbo].[RDOC],[*DEST*].[dbo].[cinf],[*SOURCE*].[dbo].[cinf]
    where [*DEST*].[dbo].[cinf].[lawsset]=[*SOURCE*].[dbo].[cinf].[lawsset]and [*DEST*].[dbo].[cinf].[version]=[*SOURCE*].[dbo].[cinf].[version] and [*SOURCE*].[dbo].[RDOC].[Doccode]NOT IN (SELECT Doccode from [*DEST*].[dbo].[RDOC])
    insert into [*DEST*].[dbo].[RITM]
    select [*SOURCE*].[dbo].[RITM].*
    from [*SOURCE*].[dbo].[RITM],[*DEST*].[dbo].[cinf],[*SOURCE*].[dbo].[cinf] where [*SOURCE*].[dbo].[RITM].[Doccode] NOT IN (select Doccode from [*DEST*].[dbo].[RITM])AND [*SOURCE*].[dbo].[RITM].[Doccode]IN (SELECT Doccode from [*DEST*].[dbo].[RDOC])
    Hope it helps...
    Grtz, Rowdy

  • How do I authorize music from the cloud from another computer

    How do I authorize music from the cloud from another computer? PowerBook4 to a Toshiba with Itunes.

    Hi there 7Corydon7,
    You may find the information in the article below helpful.
    iTunes Store: About authorization and deauthorization
    http://support.apple.com/kb/HT1420
    -Griff W.

Maybe you are looking for

  • ASA 5540 _ I want to ping across inside to outside for testing

    ASA 5540 8.2 (5) I have tried many combinations of command line syntax suggested in this forum but none are providing success so far. I want to ping from the Inside Interface across to the Outside Interface and visa versa. I have tried various ACLs a

  • Need to print the company logo in alv report

    Hi All ,        I am displaying an alv grid for some QM report .        I have used top-of-page event and   'REUSE_ALV_COMMENTARY_WRITE '    FM to display the logo and header . Every thing is working fine .   But when I am taking the print-out  the l

  • Having problems with gradient fill.

    Having problems with gradient fill. Not sure how to select the gradient circles between outer circles consistently especially when there are more than 3 colors.

  • Removing Gnome 2.30's keyboard indicator

    Hi. I've just upgraded to Gnome 2.30 and now there always is this annoying keyboard layout indicator in the tray. I use two layouts between which I switch using a keyboard shortcut. I can't find a way to remove the indicator and it's really getting o

  • How to validate Extra Fields in Journals

    Hi all. We are working with journals in SAP EPM 10, and we have created several extra fields as a part of the process. as you already know, the extra fields are dummy fields, and we would need to perform some validation when the user save or post the