Created
November 26, 2017 13:57
-
-
Save chathurangat/9b66b26830496349ef922d41e5681653 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.springbootdev.samples.springbootasynctask.worker; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.scheduling.annotation.Async; | |
import org.springframework.scheduling.annotation.EnableAsync; | |
import org.springframework.stereotype.Component; | |
@EnableAsync | |
@Component | |
public class AsyncWorker | |
{ | |
private static final Logger LOGGER = LoggerFactory.getLogger(AsyncWorker.class); | |
@Async | |
public void execute() | |
{ | |
LOGGER.info(" AsyncWorker: current thread [" + Thread.currentThread().getName() + "]"); | |
try { | |
Thread.sleep(3000); | |
} catch (InterruptedException ex) { | |
LOGGER.info(" sleeping thread interrupted "); | |
} | |
LOGGER.info(" AsyncWorker: completed [" + Thread.currentThread().getName() + "]"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment