Leave I am going to use event
Yeah, right, it should always do it is not the main thread.
You can do it without an event.
There are magic Java classes that can do (asynchronously) without using the Deprecated AsyncTask of Android, this is a bit complicated to understand (at first) so it's not advisable to use this.
Do you know about while loop and Threed.sleep() method?
I am not using any kind of while loop or for a loop.
Then how you create that
Everyone thinks in different ways.
Well I'm using Callable with FutureRunnable, callable allows you to return anything when called just like runnable but this allows you to return values as well.
You can start the Callable object through the thread to start it and invoke the get method on it.
The main thread has to do nothing but wait for the call to finish.
Can you provide me code
You should make google your friend
Ok I am going to ask with google that Do you want to do friendship with me
Let's not got too much off-topic
Tell me how you do that
Generally we implement this pattern using a method-event pair. You run the asynchronous operation and the method returns immediately. Once the processing is complete, you use the runOnUiThread
method to dispatch the event to the UI (blocks) thread. For an example, you can take a look at the File component.