ByteCode.News
Submit RSS Atom Sign in

Back to the channels

#java

  1. internecine Who uses GitHub copilot at work and is limited by tokens. How many tokens are you allotted
  2. enoq when creating a completablefuture inside a virtual thread, does the future suspend on the VT like any other I/O operation?
  3. enoq or does awaiting the future block the carrier thread that launched the VT
  4. enoq at least to me it looks like I need to provide an executor like this var executor = Executors.newVirtualThreadPerTaskExecutor();
  5. nimaje isn't a future just a container to write the result into, without any information how the result will be computed? so what happens should depend on whatever gives you that future, in the worst case it just crates it and never calls .complete(…) on it
  6. enoq my understanding is that the future forks off a new thread and then .get() blocks the thread it is on
  7. enoq what I don't know is if the default thread type is changed when running inside a VT and if .get() inside a VT suspend
  8. enoq +s
  9. nimaje that sounds more like FutureTask, how should the Future know what it should do? And where did you get that idea that it would spawn a thread? Especially as CompletableFuture has "this class has no direct control over the computation" in its docs
  10. deebo there's CompletableFuture.supplyAsync(task, executor)
  11. nimaje yeah, that is one way to create a CompletableFuture that excactly tells you how the result will be computed, even if I don't understand why that gives you a CompletableFuture instead of just a Future, are there really use cases where you want to submit some work, but have the possibility to complete it yourself some other way?
  12. Para relevant https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/concurrent/CompletionStage.html
  13. nevet CompletionStage (Java SE 21 & JDK 21)
  14. enoq maybe another way to frame this: is there a list of java APIs that suspend on virtual threads
  15. cheeser i'm not aware that libraries need to do anything for virtual threads.