Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Wait multiple tasks to finish.

 
Byeonggon Lee
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to make a JavaFX program that send multiple HTTP GET requests simultaneously without stopping main(UI) thread. After all requests are finished, the program should update its status Text to "finished".

if I would send only a single request that is easy like this:

But what I'm trying to do is sending multiple requests and setting status Text after ALL requests are finished.
What is the best way to achieve this?
 
Paul Clapham
Sheriff
Posts: 21955
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all you won't want to use Thread objects and write your own thread pool. Here's a link to Oracle's tutorial about thread pooling features which are built into the language: Thread Pools.

And as for how to do that without blocking the UI, there's a standard way to do that in JavaFX too. Here's a link to Oracle's tutorial about that: Concurrency in JavaFX.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!