This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Originally posted by Mark Mero: I am looking to create a file checker that will check the availability of multiple files. I want this to be threaded so that multiple files can be checked for at the same time.
Forgive me if you have already looked into this issue, but it seems to me that this might not be a good application for multi-threading. If all the files are on the same file system, then checking for lots of files "all at once" may not achieve improved performance.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Joined: Oct 14, 2004
Sorry if i didn't explain myself very well.
The thread will target a file checking class that will loop through the file definitions until all files have been received.
Joined: Jan 29, 2003
The logic I showed above would do the trick if each task looped inside its run method until the file existed. But it would be overkill. You don't need a thread per file, just one thread for the checker. Here's a possibility not quite in Java ...
At any moment the collection contains a list of files not yet found if anybody else is interested. You might have to synchronize any get on the remaining list.