C++ UNIX: Threading: Make Main-Thread wait or sleep until processing is over - main-thread doesnt know pthread_t refrenc
By : user3553036
Date : March 29 2020, 07:55 AM
will help you sc->start_server runs an endless loop in which a MyClass processing method is invoked in a thread. How can i replace the while(true) statement in main so that my program waits for all threads to terminate? , Use join on any thread you want to wait.
|
sleep() thread is sleeping main thread and not separate specified thread
By : Diego Hernández
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , As i can see you already know Thread.sleep is static method and only sleeps the current thread running there are 2 places where you are using sleep(). BackgroundTestRunnerThread.sleep(sleepTime * 1000); in run() method:This can not be an issue as it will be always called in BackgroundTestRunnerThread thread not in main thread. pause(int milliseconds) method: I can not see your main thread code but chances are you are calling the pause method from main assuming it will sleep the BackgroundTestRunnerThread thread but because it might be getting called from main thread it will make main thread sleep not the other one.
|
c# Thread.sleep sleep the current thread or the main thread?
By : Large Generators
Date : March 29 2020, 07:55 AM
wish helps you Thread.Sleep() sleeps the current thread. Here is the msdn documentation: Thread.Sleep
|
If there's only one thread running(main) and sleep(1000) is invoked, will the thread sleep for exactly 1 second or atlea
By : iansealy
Date : March 29 2020, 07:55 AM
it should still fix some issue Approximately 1-second pause. The thread can be woken up beforehand and you'll get an InterruptedException, or the thread can sleep for 1000ms and then not get to run immediately, so it will be 1000ms + microseconds (or more, if there are higher priority threads hogging the CPU). You're also calling it wrong. It's Thread.sleep(1000);, as a static method it always acts on the current thread and you can't make other threads sleep with it.
|
Sleep method on child Thread causing Main Thread to sleep as well
By : Ruben de Groot
Date : March 29 2020, 07:55 AM
|