Concurrent Jobs? [message #435065] |
Tue, 09 August 2005 14:08  |
Eclipse User |
|
|
|
Hi,
I have a job that downloads files. I want two or more instances of this
job to be able to run concurrently. However, when I start two or more
instances, they seem to be getting executed serially instead of
concurrently i.e the second instance waits for the first to complete, the
third waits for the second to complete and so on. I have not used join()
anywhere.
DownloadJob dj = new DownloadJob();
//set custom properties
//need to do this to show progress
dj.setUser(true);
dj.schedule();
Are there any special settings needed to enable concurrency.
Any thoughts on how I can limit the number of job instances. For example,
I don't want more than 5 instances of the DownloadJob running
concurrently. The sixth or greater job would have to wait for one of 5 to
complete. Thus, how can set the number of threads in the pool.
Thank you
Regards,
Aashish
|
|
|
|
|
|
|
Re: Concurrent Jobs? [message #435600 is a reply to message #435065] |
Fri, 19 August 2005 04:03  |
Eclipse User |
|
|
|
The most likely cause of serialised behaviour in this manner is if you're using a common 'synchronised' method to kick stuff off. For example:
public class DownloadManager {
public synchronised void download(String url) {
// ...
}
}
Even if you have multiple Jobs running this, they'll all be serialised anyway, since they're locking on the same synchronised instance. You might want to do a search for your code and find out if there's something in your code that looks fishy.
The other approach would be to run a test by creating 5 new Thread objects, and in each doing the call to your download implementation. At least that will tell you if it's a problem with your configuration/implementation of Job, or a glitch in your download code.
|
|
|
Powered by
FUDForum. Page generated in 0.05311 seconds