Re: Do I need Threads for this?




<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


.



Relevant Pages

  • Re: Do I need Threads for this?
    ... Well yes - as in my original code - ... 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 ...
    (comp.lang.java.programmer)
  • Re: Do I need Threads for this?
    ... Try calling label.repaint; ... 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 ...
    (comp.lang.java.programmer)
  • www.electronics-mac-sony.com SanDisk Sansa e250 2 GB MP3 Player with microSD Expansion Slot
    ... ultra-thin digital audio/image/video player with 2 GB of flash ... Memory capacity: 2 GB ... Voice recording: Supported ... The Sansa e250 will play MP3, WMA, and secure WMA formats. ...
    (microsoft.public.windowsmedia.player)
  • Re: Freezing, Pixilation and Stuttering When Watching Live and Recorde
    ... Depending on memory size, and if protected content is involved I/O could still be going on because of the software overhead. ... In addition to this polling, further device-specific polling is also done, for example Vista polls video devices on each video frame displayed in order to check that all of the grenade pins are still as they should be. ... Time will tell whether this problem is due to immature drivers or has been caused by the overhead imposed by Vista's content protection mechanisms interfering with playback..." ... a recording on my second drive. ...
    (microsoft.public.windows.mediacenter)
  • Re: Freezing, Pixilation and Stuttering When Watching Live and Rec
    ... I guess I should have highlighted the MCE 2005 part in the computer spec's. ... Depending on memory size, and if protected content is involved (or ... for example Vista polls video ... a recording on my second drive. ...
    (microsoft.public.windows.mediacenter)