I have a button, when user tap the button, i run a Thread to do Something.
When user tap many time to my button, i have many thread run in a same time.
How can i avoid it, when user multiple tap, i have run only thread run. When the first thread complete, the second thread can run.
Thanks
You need to keep a boolean that indicates you’ve acted on the click and started the thread. Something like this:
Note: Don’t forget to reset the boolean to false after the thread has completed