Created
May 29, 2017 12:24
-
-
Save luismoramedina/ee175da332a992e82340606ec76d35f5 to your computer and use it in GitHub Desktop.
Background task in controller
This file contains hidden or 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
@RequestMapping("/job/start") | |
public String start() throws ExecutionException, InterruptedException { | |
ExecutorService executor = Executors.newSingleThreadExecutor(); | |
executor.submit(() -> { | |
try { | |
System.out.println("BGController.before"); | |
Thread.sleep(10000); | |
System.out.println("BGController.after"); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
}); | |
return "start"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment