packagecom.sam.schedule;importorg.springframework.scheduling.annotation.Async;importorg.springframework.stereotype.Component;@ComponentpublicclassAsyncWorker{@Asyncpublicvoidwork(Stringname){StringthreadName=Thread.currentThread().getName();System.out.println(" "+threadName+" beginning work on "+name);try{Thread.sleep(5000);// simulates work
}catch(InterruptedExceptione){Thread.currentThread().interrupt();}System.out.println(" "+threadName+" completed work on "+name);}}