Re: Do I need Threads for this?




Oliver Wong wrote:
<nospam@xxxxxxxxxxxxxxx> wrote in message
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...

snip
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--

.



Relevant Pages

  • Why the Podunk County School will never be using Java and will probably never leave VB
    ... And of course, Java, and .NET, provide all kinds of wizzo high-level ... Let's try a simple task in Visual Studio .NET, Eclipse and Netbeans. ... hey, lets go with it. ... click it and, hmm, ...
    (comp.lang.java.softwaretools)
  • Re: Java Instanz und Objekt frage ?
    ... QED. ... Hmm. ... Die Behauptung war "In Java gibt es globale Variablen." ... > darin, dass Klassenvariablen erzeugt werden, wenn die Klasse im Rahmen ...
    (de.comp.lang.java)
  • Re: Generics, Type safety
    ... oder mit methodenspezifischer Typvariable gegebenen) Typparameter. ... (Hmm, ich sehe schon das Problem, wenn eine Methode einen ... So steht es auch in der JLS und es steht auch drin, dass Raw-Types eines Tages ganz aus der Sprache Java wieder verschwinden können. ... The use of raw types in code written after the introduction of genericity into the Java programming language is strongly discouraged. ...
    (de.comp.lang.java)
  • Re: [Challenge] die Sache mit dem Rechteck (was: Re: Frage zu verdecktem Member)
    ... Gleiches gilt für Rechtecke. ... Hmm, ich glaube da bräuchte man die bedingten Typen ... template object Rectangle isa shape; ... The Java Virtual Machine Specification: ...
    (de.comp.lang.java)
  • Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
    ... >>> There are some things that Java doesn't do, ... > Oh, they are probably teaching lots of abstract theory, on the basis ... > exotic, awkward, or unpopular languages. ... thinking has not been perverted by languages that are mere Von Neumann ...
    (comp.programming)