I'm trying to make a game, which includes a thread with a 10 seconds Thread.sleep in it, that gives the player a maximum time to react (when the sleep ends and he/she didn't choose anything, new stuff appears and it's a lost life). However if the player hit an option (no matter if it is the correct one or not), new stuff should appear immediately and the sleep should be "cancelled" in order to restart those 10 seconds. In other words, right now if at first I have 10 seconds, but after three seconds I hit an option, then I just have 7 seconds more before my interface change, when it should be another 10... I know I cannnot break that sleep, but how can I accomplish this? I'm not posting any line of code, because I would like to undertand the concept first, and then I can figure it out.
How to cancel a n-second Thread.sleep in order to restart it in android?
146 views Asked by user3053894 At
1
There are 1 answers
Related Questions in ANDROID
- Creating global Class holder
- Flutter + Dart: Editing name of a tab shows up a black screen
- android-pdf-viewer Received status code 401 from server: Unauthorized
- Sdk 34 WRITE_EXTERNAL_STORAGE not working
- ussd reader in Recket Native module
- Incorrect display of LinearGradientBrush in IOS
- The Binary Version Of its metadata is 1.8.0, expected Version is 1.6.0 build error
- I can't make TextInput to auto expand properly in Android
- Creating multiple instances of a class with different initializing values in Flutter
- How to create a lottie animation
- making android analyze with coverity sast tool
- Flutter plugin development android src not opening after opening example
- I initialize my ViewModel in the Activity with several fragments as tabs, but the fragments(tabs) return null for the updated livedata
- Node.js Server + Socket.IO + Android Mobile Applicatoin XHR Polling Error...?
- How I can use the shared preferences class?
Related Questions in MULTITHREADING
- How can I outsource worker processes within a for loop?
- OpenMP & oneTbb difference
- Receiving Notifications for Individual Task Completion OmniThreadLibrary Parallel.ForEach
- C++ error: no matching member function for call to 'enqueue' futures.emplace_back(TP.enqueue(sum_plus_one, x, &M));
- How can I create a thread in Haskell that will restart if it gets killed due to any reason?
- Qt: running callback in the main thread from the worker thread
- Using `static` on a AVX2 counter function increases performance ~10x in MT environment without any change in Compiler optimizations
- Heap sort with multithreading
- windows multithreading CreateMutex
- The problem of "fine-grained locks and two-phase locking algorithm"
- OpenMP multi-threading not working if OpenMPI set to use one or two MPI processor
- WPF Windows Initializing is locking the separated thread in .Net 8
- TCP Client Losing Connection When Writing Data
- vc++ thread constructor throwing compiler error c2672
- ASP.NET Core 6 Web API : best way to pause before resending email
Related Questions in DELAY
- How to use dynamic value for start_in using environment variable in gitlab pipeline child job
- Time Delay while sending data through UART using WriteFile intervally for some duration
- Joomla 5..0.3 delay in search
- How to make a proper delay in a microcontroller?
- ID getting lost during delayed job
- Hangfire - Execution function time is not match with the scheduled job time
- Tkinter and animation.FuncAnimation accumulating delay and freeze GUI
- PyWinAuto.Application().connect(pid).window(windowName).send_keystrokes take way longer than keyboard.press()
- I struggle with a basic feedback delay network
- Nucleo STM32L4 non blocking timer within interrupt
- How to add delay
- How to know if someone has read a post based on time to read
- Webrtc recording delay on windows
- Calling a function after updateable delay in C++?
- Ultrasonic Sensor With Interrupts on Nucleo board Inaccurate
Related Questions in THREAD-SLEEP
- ASP.NET Core 6 Web API : best way to pause before resending email
- Thread.Sleep() vs Task.Delay().Wait()
- Spring API throw interrupt signal when using Thread.sleep()
- Looking for clarity on Thread.sleep() method
- How to replace Thread.sleep with WebDriverWait to avoid StaleElementReferenceException
- The problem of waking up existing threads in the ThreadPool
- How can I avoid Chrome to suspend my app tab?
- Using Thread Sleep in an application to Control a motor - Is there a better alternate
- How to remove a letter from the terminal and replace it with a new one in java?
- Selenium - the .click() command is not executed when I use Explicit Wait but when I use Thread.sleep it does
- I need to use locks but dont know how in a networking problem
- With very short sleep times, why does a thread only finish zero or one iteration of printing before seeing the stop flag set?
- counting a vector containing random numbers ranging from 0 to 9 using threads
- Why is my app not waiting when using sleep
- JProgressBar moves instantly and not gradually (java)
Related Questions in THREAD-ABORT
- Get last executed code statement after thread is aborted
- C# ThreadAbortException, find who is calling the abort
- How can I abort a thread to ensure the application doesn't get stuck?
- Canceling Multiple Threads
- How to stop multiple threads (Tasks) from an external REST API call?
- Abort AWT application
- Immediately abort an asynchronous task c#
- How to use thread.abort()
- Do static constructors run as CERs?
- How to implement Thread.ResetAbort method in Python
- How to use Thread.Abort() properly?
- .NET Core equivalent to Thread.Abort
- Occasional thread abort exception
- Thread is not aborted and waits on dispatcher invoke?
- App is crashing on launch screen(on iPad 10.2)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
To restard the app in android use the following Code: