Work manager using thread.sleep or delay doesn't work

By : Mr.K

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;

        public void run() {

    private TaskExecutor taskExecutor;
    public TaskExecutorSample(TaskExecutor taskExecutor){
        this.taskExecutor = taskExecutor;
        try {
            while (shutdown.equals(Boolean.FALSE)){
        } catch (Exception e) {

    public void printMessage() {
        taskExecutor.execute(new MessageGenerator("Print this Messages"));

Really thanks in advance. Regards,


By : Mr.K


Well, the thread will wait for a bit more than 2h. Did you really wait that long for the deployment to finish?

[EDIT] You're probably doing the wait in the wrong place: You should wait in the run() method of the thread, not the constructor of the class.

This video can help you solving your question :)
By: admin