|  |  | @ -7,7 +7,6 @@ import org.springframework.web.bind.annotation.RequestMapping; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import java.time.LocalDateTime; | 
			
		
	
		
			
				
					|  |  |  | import java.util.concurrent.Callable; | 
			
		
	
		
			
				
					|  |  |  | import java.util.concurrent.ExecutionException; | 
			
		
	
		
			
				
					|  |  |  | import java.util.concurrent.ExecutorService; | 
			
		
	
		
			
				
					|  |  |  | import java.util.concurrent.Future; | 
			
		
	
	
		
			
				
					|  |  | @ -32,6 +31,9 @@ public class DemoController { | 
			
		
	
		
			
				
					|  |  |  |         demoService.testTx(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * 异步方式1,手动submit | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @GetMapping("testthreadpool") | 
			
		
	
		
			
				
					|  |  |  |     public void testThreadPool() { | 
			
		
	
		
			
				
					|  |  |  |         System.out.println(LocalDateTime.now().getSecond());; | 
			
		
	
	
		
			
				
					|  |  | @ -43,7 +45,7 @@ public class DemoController { | 
			
		
	
		
			
				
					|  |  |  |         Future<Boolean> future3 = executorService.submit(() -> demoService.testThreadPool()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             // 可以获取返回值,此处会阻塞
 | 
			
		
	
		
			
				
					|  |  |  |             Boolean o1 = future1.get(); | 
			
		
	
		
			
				
					|  |  |  |             System.out.println(LocalDateTime.now().getSecond()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -61,6 +63,9 @@ public class DemoController { | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * 异步方式2,service方法中加注解@Async | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @GetMapping("testthreadpoolasyncs") | 
			
		
	
		
			
				
					|  |  |  |     public void testThreadPoolAsync() { | 
			
		
	
		
			
				
					|  |  |  |         System.out.println(LocalDateTime.now().getSecond()); | 
			
		
	
	
		
			
				
					|  |  | 
 |