Inter-thread communication (worker threads)

后端 未结 4 574
轻奢々
轻奢々 2021-01-24 13:05

I\'ve created two threads A & B using CreateThread windows API. I\'m trying to send the data from thread A to B.

I know I can use Event object and wait for the Event

4条回答
  •  别那么骄傲
    2021-01-24 13:49

    If you are concerned with minimizing Windows dependencies, and assuming you are coding in C++, then I recommend using Boost.Threads, which is a pretty nice, Posix-like C++ threading interface. This will give you easy portability between Windows and Linux.

    If you go this route, then use a mutex to protect any data shared across threads, and a condition variable (combined with the mutex) to signal one thread from the other.

提交回复
热议问题