Global variable vs Events in multi threading

drjackool 956 Reputation points

In Win32 apps (VC++) what is difference between using global variable and events to signal the thread?
What are pros and cons

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,479 questions
0 comments No comments
{count} votes

Accepted answer
  1. RLWA32 41,996 Reputation points

    One obvious difference is that a thread would poll to detect a change in a global variable while the wait functions with an event avoid polling. Or, you could use WaitOnAddress but that comes with its own considerations - WaitOnAddress lets you create a synchronization object out of any data variable, even a byte

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 11,746 Reputation points Microsoft Vendor
    0 comments No comments