thread-sleep Questions
4
Solved
I want to run a function periodically every 1 second, so after 10 seconds it is executed 10 times.
The simplest approach is using a loop like this :
while(true)
{
Thread.Sleep(1000);
function();
}...
Quimper asked 11/10, 2012 at 7:48
5
Solved
How can I pause execution for a certain amount of time in Godot?
I can't really find a clear answer.
Imamate asked 1/7, 2022 at 13:45
2
Solved
In my test class, I really need to sleep for some amount of time. It's an integration test involving periodic remote call.
for (int i = 0; i < 16; i++) {
// sleep some... should sleep some...
...
Dump asked 4/3, 2022 at 4:28
6
Solved
I did some reading of other post but didn't find an exact answer to what I'm looking for, so I hope someone can give some some clarification.
I have a program that will run for some time. I have s...
Irruption asked 8/6, 2014 at 22:17
6
Solved
I have an app with 2 threads (now), but it seems that function Thread.Sleep() doesn't work very good. It sleeps threads but it takes much more time (for example- I want to sleep it for 5ms and it s...
Condescension asked 13/1, 2012 at 1:23
6
Solved
Pls help me to understand how can we make a thread to sleep for a infinite time period .
Reinaldo asked 15/6, 2015 at 12:45
2
Guys how to deal with such code and warning?
private void listenOnLogForResult() {
String logs = "";
int timeCounter = 1;
while (logs.isEmpty()) {
try {
timeCounter++;
Thread.sleep(...
Crespi asked 23/3, 2021 at 13:50
6
Solved
First off, I am a beginner in C# and I would like to make this:
class2.method_79(null, RoomItem_0, num, num2, 0, false, true, true);
System.Threading.Thread.Sleep(250);
class2.method_79(null, Room...
Mariettemarigold asked 10/6, 2014 at 8:35
3
Solved
Presumptions/Prelude:
In previous questions, we note that Thread.Sleep blocks threads see: When to use Task.Delay, when to use Thread.Sleep?.
We also note that console apps have three threads: The...
Ulane asked 17/5, 2022 at 19:34
7
Solved
I know Thread.sleep() can make a java thread suspend for a while, like certain milliseconds and certain nanoseconds. But the problem is the invocation of this function also causes overhead.
For e...
Fibrinolysis asked 16/7, 2012 at 5:35
8
Solved
I am trying to do something in Java and I need something to wait / delay for an amount of seconds in a while loop.
while (true) {
if (i == 3) {
i = 0;
}
ceva[i].setSelected(true);
// I need ...
Vassallo asked 8/6, 2014 at 8:26
2
Solved
I tried to use the below code to make a 2 second delay before navigating to the next window. But the thread is invoking first and the textblock gets displayed for a microsecond and landed into the ...
Bilicki asked 24/3, 2013 at 14:50
5
The following code:
long msBefore = System.currentTimeMillis();
//Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
try
{Thread.sleep(200);
} catch (InterruptedException e){}
System.out.pri...
Iinde asked 23/5, 2011 at 10:7
5
Solved
My question is a bit nit-picky on definitions:
Can the code below be described as "busy waiting"? Despite the fact that it uses Thread.Sleep() to allow for context switching?
while (true) {
if (...
Jehiel asked 8/7, 2014 at 11:27
3
Solved
I use Thread.sleep when experimenting or demonstrating Java code for concurrency. By sleeping, I am faking some processing work taking place that will take some time.
I wonder about doing this unde...
Woollyheaded asked 17/12, 2020 at 0:46
3
Solved
Is there a way in python to interrupt a thread when it's sleeping?
(As we can do in java)
I am looking for something like that.
import threading
from time import sleep
def f():
print('start...
Casar asked 8/8, 2016 at 11:55
1
Solved
So I've written the following function to show what i mean:
use std::{thread, time};
const TARGET_FPS: u64 = 60;
fn main() {
let mut frames = 0;
let target_ft = time::Duration::from_micros(1000...
Legg asked 27/7, 2020 at 8:6
3
Solved
I call this function in my centos 7 server.
I find std::this_thread::sleep_for(chrono::nanoseconds(1)) actually sleep for one ms, Is there any explanation? I think it may be caused by os setting?
Lamkin asked 8/3, 2020 at 6:7
3
Solved
If I put two calls side-by-side to determine the smallest measurable time duration:
// g++ -std=c++11 -O3 -Wall test.cpp
#include <chrono>
typedef std::chrono::high_resolution_clock hrc;
hr...
Draughtsman asked 6/8, 2013 at 4:9
2
Solved
Note, this is not a question about std::condition_variable::wait_for(). I know that can wake spuriously.
My program’s behavior suggests the answer to this question is Yes, but the STL docume...
Covet asked 29/5, 2015 at 20:29
1
Solved
After updating Jenkins to version 2.156 (from version 1.6), some of our build jobs get stuck after completing and before moving to post-build action. Job itself is finished within 5 minutes (same a...
Keldon asked 4/1, 2019 at 12:43
4
Solved
Goal: Execute certain code every once in a while.
Question: In terms of performance, is there a significant difference between:
while(true) {
execute();
Thread.sleep(10 * 1000);
}
and
execut...
Airmail asked 16/11, 2012 at 18:11
1
Solved
Like below link, is there java function that thread interrupt asynchronous queue and put in alertable?
https://learn.microsoft.com/en-us/windows/desktop/sync/using-a-waitable-timer-with-an-asynchr...
Feuar asked 14/12, 2018 at 22:43
2
Solved
Having some problem getting my program to sleep
What im trying to do is when the btnStart is pressed firs randomly set pictures to 12 ImageButtons
Then i want it to pause for 5 secs and then ...
Tearoom asked 3/12, 2011 at 18:1
1
Solved
A few threads are started in my code and I need at the end of the script to sleep indefinitely, without this sleep being a major hit on the performance1.
One possibility can be to loop indefinite...
Finagle asked 7/5, 2018 at 14:44
1 Next >
© 2022 - 2024 — McMap. All rights reserved.