Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1015885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:28:01+00:00 2026-05-16T10:28:01+00:00

It is best to describe my question in an example: We create a Windows

  • 0

It is best to describe my question in an example:

  1. We create a Windows Event handle by CreateEvent, with manualReset as FALSE.
  2. We create 4 threads. Ensure that they all start running and waiting on the above event by WaitForSingleObject.
  3. In the main thread, in a for loop, we signal this event 4 times, by SetEvent. such as:

    for (int i = 0; i < 4; ++i) ::SetEvent(event);

My question is, can we say that all these 4 threads will certainly be waken up from waiting on this event?

According to my understanding of Windows Event, the answer is YES. Because when the event is set, there is always a thread waiting for it.

However, I read on MSDN that “Setting an event that is already set has no effect“. Since the waiting threads probably do not get a chance to run while main thread setting event in the loop. Can they still be notified and reset the event to nonsignaled? If the event is not reset, the following SetEvent in the loop is obviously useless.

Or the OS kernel knows which thread should be notified when an event is set, and reset this event immediately if there is a waiting thread. So the waiting thread does not need to be schedule to reset the event to nonsignaled?

Any clarification or references are welcome. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:28:02+00:00Added an answer on May 16, 2026 at 10:28 am

    Because when the event is set, there is always a thread waiting for it.

    No, you don’t know that. A thread may indefinitely suspended for some reason just before the NtWaitForSingleObject system call.

    Since the waiting threads probably do not get a chance to run while main thread setting event in the loop.

    If a thread is waiting for an object, it doesn’t run at all – that’s the whole point of being able to block on a synchronization object.

    Can they still be notified and reset the event to nonsignaled? If the event is not reset, the following SetEvent in the loop is obviously useless.

    The thread that sets the event is the one that resets the signal state back to 0, not the thread that gets woken up. Of course, if there’s no thread waiting the signal state won’t be reset.

    Or the OS kernel knows which thread should be notified when an event is set, and reset this event immediately if there is a waiting thread.

    Yes, the kernel does know. Every dispatcher object has a wait list, and when a thread waits on an object it pushes a wait block onto that list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is best described in code. I have a class called Vertex that
I am having a couple of issues deciding how best to describe a certain
The best that I have been able to come up with is: strlen(preg_replace('/^([\\*]*)\s(.+)/',$1,$line)); ^^That
Best recommendations for accessing and manipulation of sqlite databases from JavaScript.
How best to make the selected date of an ASP.NET Calendar control available to
For best performance, is it better to use a virtual IDE HDD or virtual
As best-behaved as I try to be about keeping my unit tests disconnected from
How best can I convert instances of double backslashes to a single backslash in
What best practices should be observed when implementing HDL code? What are the commonalities
The best I can come up with for now is this monstrosity: >>> datetime.utcnow()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.