Reputation: 2028
How to check when a particular process has been finished? In my scenario download, process, upload is happening sequentially.
Below is what I'm trying to accomplish -
1) Downloading an excel file from a server (Size varies - which is the reason I'm trying to check time)
call S3DataGetUrlForDownload( parameters )
2) Process the excel file inside java servlet, upload it to an API (which is different from the first server).
upload.fileUpload( parameters );
Never programmed with the threads/timers. Added this part of sleep code, but when excel is big it fails.
try {
Thread.sleep(2000);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
Upvotes: 0
Views: 82
Reputation: 311023
If you're doing it in another thread, don't do it in another thread. Then 'process completion' basically becomes 'the called method returns'.
Upvotes: 1
Reputation: 6054
In the thread class there is a method named join that will block until that thread completes execution. Just call that for your download/worker thread (from main thread) and it will behave the same as if you called Thread.sleep with exactly the right time.
Upvotes: 0