What is a race condition?

后端 未结 18 2511
谎友^
谎友^ 2020-11-21 04:52

When writing multithreaded applications, one of the most common problems experienced is race conditions.

My questions to the community are:

What is the rac

18条回答
  •  礼貌的吻别
    2020-11-21 05:28

    You don't always want to discard a race condition. If you have a flag which can be read and written by multiple threads, and this flag is set to 'done' by one thread so that other thread stop processing when flag is set to 'done', you don't want that "race condition" to be eliminated. In fact, this one can be referred to as a benign race condition.

    However, using a tool for detection of race condition, it will be spotted as a harmful race condition.

    More details on race condition here, http://msdn.microsoft.com/en-us/magazine/cc546569.aspx.

提交回复
热议问题