Browse Source

1.修改注释

master
wxz 5 years ago
parent
commit
62bb828309
  1. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java

@ -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 {
}
}
/**
* 异步方式2service方法中加注解@Async
*/
@GetMapping("testthreadpoolasyncs")
public void testThreadPoolAsync() {
System.out.println(LocalDateTime.now().getSecond());

Loading…
Cancel
Save