Advertisement
Guest User

Bean

a guest
Mar 31st, 2017
731
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.65 KB | None | 0 0
  1. package it.dstech.cloud.beans;
  2.  
  3. import java.util.concurrent.Future;
  4.  
  5. import org.slf4j.Logger;
  6. import org.slf4j.LoggerFactory;
  7. import org.springframework.scheduling.annotation.Async;
  8. import org.springframework.scheduling.annotation.AsyncResult;
  9.  
  10. public class TestAsync {
  11.     static final Logger logger = LoggerFactory.getLogger(TestAsync.class);
  12.  
  13.     public TestAsync() {
  14.     }
  15.    
  16.     @Async
  17.     public Future<String> call(){
  18.         try {
  19.             Thread currentThread = Thread.currentThread();
  20.             logger.debug(currentThread.getName());
  21.             Thread.sleep(10000);
  22.         } catch (InterruptedException e) {
  23.             e.printStackTrace();
  24.         }
  25.         return new AsyncResult<>("Ciao");
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement