I have several methods (involving network operations) which take quite a long time. I want to call them asynchronously and check the status from time to time. What’s the recommended way to do it in Java?
I have several methods (involving network operations) which take quite a long time. I
Share
I would use a FutureTask.
You give it the task, you can provide code to be run when the task is over (the protected
donemethod), and you can check it’s status with theisDonemethod.If you’re writing a swing application you could also use SwingWorker