| |

VerySource

 Forgot password?
 Register
Search
View: 587|Reply: 1

Efficiency issues: who uses the timer and sleep () in the thread, who is more efficient

[Copy link]

3

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 Ukraine

Post time: 2020-1-11 02:40:01
| Show all posts |Read mode
If you want to do the same thing continuously:
1: Use sleep ()
while (TRUE)
{
sleep (100);
}

2: Using timer events
============================

Which of these two methods is more efficient and consumes less resources, provided that it is in the "" thread ""
Reply

Use magic Report

0

Threads

36

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-1-20 11:27:01
| Show all posts
It may be that Sleep occupies less resources, and the thread does not need to be scheduled when it is sleeping. It also needs to accept thread messages when using the timer message processing function.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list