GitHub user polarisGitHub edited a discussion: [Q/A][Java SDK (Component)] For
asynchronous calls, should I use asyncCall or virtual threads?
### Pre-check
- [ ] I am sure that all the content I provide is in English.
### Apache Dubbo Component
Java SDK (apache/dubbo)
### Details
Which way is better?
```java
try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
Future<A> fa = executor.submit(() -> remoteService.query(req));
// do somethings
A a = fa.get();
Result result = future.get();
}
```
```java
CompletableFuture<Result> future = RpcContext.getServiceContext().asyncCall(()
-> remoteService.query(req));
// do somethings
Result result = future.get();
```
### Code of Conduct
- [X] I agree to follow this project's [Code of
Conduct](https://www.apache.org/foundation/policies/conduct)
GitHub link: https://github.com/apache/dubbo/discussions/16379
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]