1.消息处理,需要完成两件事情

public boolean expend(Object body) {
  

	AtomicBoolean flag = new AtomicBoolean(true);
	// 第一件事
	CompletableFuture<Void> f1 = CompletableFuture.runAsync(() -> {

		doThingOne(body);

	}, ThreadPool.pool).exceptionally((e) -> {
		flag.set(false);
		return null;
	});

	// 第二件事
	CompletableFuture<Void> f2 = CompletableFuture.runAsync(() -> {

		doThingTwo();
	}, ThreadPool.pool).exceptionally((e) -> {
		flag.set(false);
		return null;
	});

	CompletableFuture.allOf(f1, f2).join();

	return flag.get();
}

  

相关文章:

  • 2023-03-19
  • 2023-04-06
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2021-10-13
  • 2023-03-21
猜你喜欢
  • 2022-01-30
  • 2022-12-23
  • 2021-09-22
  • 2022-02-21
  • 2021-06-03
  • 2021-10-31
  • 2022-12-23
相关资源
相似解决方案