Hi all, I used Spring framework and oracle weblogic 10.3 as a container. I used workmanager for manage my thread, I already made one thread that managed by workmanager. Fortunately spring provide the delegation class for using workmanager, so I just need to put it on applicationContext.xml.
But when I put the "while" and TimeUnit for sleep the process on desired delayed time, the deployment process never finished. It seems the deployment process never jump out from while loop for finishing the deployment.
Why?, As I know using typical thread, there is no issue like this. Should I use another strategy for make it always loop and delay.
import java.util.concurrent.TimeUnit;
import org.springframework.core.task.TaskExecutor;
public class TaskExecutorSample{
Boolean shutdown = Boolean.FALSE;
int delay = 8000;
TimeUnit unit = TimeUnit.SECONDS;
private class MessageGenerator implements Runnable {
private String message;
public MessageGenerator(String message){
this.message = message;
}
@Override
public void run() {
System.out.println(message);
}
}
private TaskExecutor taskExecutor;
public TaskExecutorSample(TaskExecutor taskExecutor){
this.taskExecutor = taskExecutor;
try {
while (shutdown.equals(Boolean.FALSE)){
this.printMessage();
unit.sleep(delay);
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public void printMessage() {
taskExecutor.execute(new MessageGenerator("Print this Messages"));
}
}
Really thanks in advance. Regards,
Kahlil