Re: Do I need Threads for this?
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Tue, 5 Dec 2006 13:01:03 -0500
<nospam@xxxxxxxxxxxxxxx> wrote in message
news:-8KdnV_9A7YpBujYnZ2dnUVZ8s2dnZ2d@xxxxxxxxx
Presumably the thread which is doing the file-copying will update some
region in memory, recording it's progress. E.g. "Okay, I'm done with file
#4... now I'm done with #5... #6...", periodically releasing the CPU
Well yes - as in my original code -
mycopyOverFileMethod();
count++;
label.setText("Files Copied:" + count);
- this copies the file, when that's done, surely, the thread continues
onto count++ (recording in memory where its got to) and then sets the
label.
Why does my label not update before going back around in the for loop to
do another file copy? Surely the processor is freed up to do the lines
after the mycopyOverFileMethod() before doing this method again? That's
why I'm confused!
I'm guessing your code is running in the EDT, the Event Dispatch Thread,
which AWT/Swing implicitly creates for you as soon as you use them for GUIs.
Because your code is running in the EDT, the EDT is not free to do other
stuff, like actually take the changes caused by label.setText(), and render
them onto the screen.
- Oliver
.
- References:
- Do I need Threads for this?
- From: nospam
- Re: Do I need Threads for this?
- From: DRS.Usenet@xxxxxxxxxxxxxxxx
- Re: Do I need Threads for this?
- From: nospam
- Re: Do I need Threads for this?
- From: Oliver Wong
- Re: Do I need Threads for this?
- From: nospam
- Do I need Threads for this?
- Prev by Date: Re: Chr function
- Next by Date: Re: javamail code in servlet works locally, but not when uploaded to host
- Previous by thread: Re: Do I need Threads for this?
- Next by thread: Re: Do I need Threads for this?
- Index(es):
Relevant Pages
|