Re: Do I need Threads for this?
- From: "DRS.Usenet@xxxxxxxxxxxxxxxx" <DRS.Usenet@xxxxxxxxxxxxxxxx>
- Date: 5 Dec 2006 09:46:31 -0800
Oliver Wong wrote:
<nospam@xxxxxxxxxxxxxxx> wrote in messagesnip
news:loWdnZQDa8Q3DOjYRVnyuQ@xxxxxxxxx
Yes, you need threads, but it's not that hard. You make a class that
implements Runnable or extends Thread. Then you can do all ten files
at once, if you choose to!
Hmm, seems a bit awkward, but then Java seems that way sometimes...
saying that I don't understand how the thread processes interact with each
other...
Presumably the thread which is doing the file-copying will update some
region in memory, recording it's progress.
Yeah, sorta, but when I think about doing things in Java, I try not to
think of memory regions. The idea has already been expressed above:
You pass a reference of "yourself" (ie "this") to the thread doing the
copy. Then you can do lots of stuff, like call a method in "yourself"
from the spun-off thread. And/or you can use "join" that waits for all
of your threads to complete. I didn't look at that example link, but I
imagine that would be a really good way to start (that is, unless
someone more energetic than I writes you a snippet or two... it really
wouldn't be many lines of code... like 15 maybe).
--Dale--
--Dale--
.
- 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
- Do I need Threads for this?
- Prev by Date: Re: Unicode to numerical value ?
- Next by Date: Re: Unicode to numerical value ?
- Previous by thread: Re: Do I need Threads for this?
- Next by thread: Re: Do I need Threads for this?
- Index(es):
Relevant Pages
|