Java Question Manage long operations without blocking main thread


Well-Known Member
Licensed User
Longtime User
Sorry, I do not know you, I just need one operation at time on the library, I do not know because I need to count operations.
Every function have it's Runnable, what I need is to just call an operation and wait to finish.
PS: You might need to use the synchronized keyword or use locks for thread safety, the sample above is untested.
This is a problem, I'm not so good on Java.

I still read about executor, you used:
final Executor executor = Executors.newSingleThreadExecutor();
this prevents to execute more thead at time?
I cannot use executor.shoutdown() or something similar when operation is finisched and prevent other functions to be executed (just put in quee) until current operation was finished?

Maybe put an executor as global variable in a class so it do just one thread at time waiting until it finish ?