Hi all, I hope someone can offer some input. I am working on a file Upload applet and I want to implement batch upload. In other words, a user selects 5 images and then hits the upload button. The files will be sent as one group while these are uploading the user selects a another 5 images and these get sent as another group.However, they only get sent after the first group as finished uploading. So I wanted to implement a Upload Manager that implements Runnable. It will run in the background and receive new batches of files. This batch file object will also implement Runnable and connect to the server and send the files. While sending the first batch the Upload Manager can still receive other batch file objects but will store them until they are ready to be sent. Can anyone see from this description how this would be done. Would it be done using a Thread pool or a queue of some sort?? Regards David
Joined: Jan 29, 2003
Sounds like the UploadManager needs to run on its own thread. The main program thread puts jobs into queue. The UploadManager pulls a job from the queue and executes it. In your case, the job would be one "group" of uploads. If there are no jobs in queue, the UploadManager might sleep for a while. Maybe the queue would interrupt it to wake it up when a client put a new job into an empty queue. Any of that make sense? Bottom line sounds like just one new thread needed for UploadManager. Unless you want it to spawn a new thread per file so a group of five could all run at once.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Sep 27, 2002
Well what I would like to have is: (note batch implements runnable as does upload manager) UploadManager waits for a new batch to be added. It is constantly waiting. So all UploadManager does is waits for a new Batch if there are no other batches in queue execute run method of new batch if there is a batch running place in queue.When running batch ends check que for another one to execute. How do I have a thread that is constantly waiting for a new batch to be added? regards david