Article View: borland.public.jbuilder.java.api
Article #2271Re: Waiting for a thread to finish
From: Torsten Welches
Date: Mon, 16 Apr 2001 17:31
Date: Mon, 16 Apr 2001 17:31
22 lines
1851 bytes
1851 bytes
Al, obviously you join the awt event dispatch thread with your worker thread. Join suspends the waiting thread so your app appears to freeze. I re-read your initial post: you say you do the download in a background thread and need to enable/disable a button accordingly. In pseudo-code that would be: button.setEnabled(false); thread.start(); and in your Thread's run method (or Runnable) call button.setEnabled(true) as the last instruction. Unfortunatelly most Swing methods are not thread-safe, so you have to post the setEnabled to the event dispatch thread. Here's some background information: http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html Torsten Al Mal schrieb in Nachricht <3adafaa4_1@dnews>... >In this case application will be frozen. I mean different: something like >Delphi's OnTerminate event handler.
Technical Details
Message-ID:
<3adb2bb7_2@dnews>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone2.usenetserver.com!news-out.usenetserver.com!atl1-feed1.news.digex.net!sfo2-feed1.news.digex.net!intermedia!logbridge.uoregon.edu!nntp-relay.ihug.net!ihug.co.nz!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3ada7468$1_1@dnews> <3adac7cd_1@dnews> <3adafaa4_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,609fa558749ab800 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2001-04-16 11:00:03 PST From: "Torsten Welches" <torsten.welches@who.cares.netcologne.de> Newsgroups: borland.public.jbuilder.java.api References: <3ada7468$1_1@dnews> <3adac7cd_1@dnews> <3adafaa4_1@dnews> Subject: Re: Waiting for a thread to finish Date: Mon, 16 Apr 2001 19:31:06 +0200 Lines: 25 X-Newsreader: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 NNTP-Posting-Host: 195.14.250.176 Message-ID: <3adb2bb7_2@dnews> X-Trace: dnews 987442103 195.14.250.176 (16 Apr 2001 10:28:23 -0700) Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone2.usenetserver.com!news-out.usenetserver.com!atl1-feed1.news.digex.net!sfo2-feed1.news.digex.net!intermedia!logbridge.uoregon.edu!nntp-relay.ihug.net!ihug.co.nz!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews