Synchronized method called from next batch even though previous batch is not completed its execution in synchronized method.
public class FTPClientInvocation implements Job {
public FTPClientInvocation() {
}
// Quartz Scheduler will invoke this method
public void execute(JobExecutionContext context)
throws JobExecutionException {
FTPClient ftpClient = new FTPClient();
ftpClient.retriveFiles();
}
}
FTPClient.java class is
public class FTPClient {
public synchronized void retriveFiles() {
// from here multi threading code is called for some file execution.
}
}
I am expecting that retriveFiles() method will be invoked only when current batch completes its execution but it is not happening here. Next batch starts executing retriveFiles() method. I have tried to add @DisallowConcurrentExecution annotation on top of FTPClientInvocation class but it also doesn't help.
@DisallowConcurrentExecution
public class FTPClientInvocation implements Job {
public FTPClientInvocation() {
}
// Quartz Scheduler will invoke this method
public void execute(JobExecutionContext context)
throws JobExecutionException {
FTPClient ftpClient = new FTPClient();
ftpClient.retriveFiles();
}
}