How to detect and debug multi-threading problems?

前端 未结 17 1883
陌清茗
陌清茗 2020-11-29 16:12

This is a follow up to this question, where I didn\'t get any input on this point. Here is the brief question:

Is it possible to detect and debug problems co

17条回答
  •  死守一世寂寞
    2020-11-29 16:39

    Apart from crash dumps, a technique is extensive run-time logging: where each thread logs what it's doing.

    The first question when an error is reported, then, might be, "Where's the log file?"

    Sometimes you can see the problem in the log file: "This thread is detecting an illegal/unexpected state here ... and look, this other thread was doing that, just before and/or just afterwards this."

    If the log file doesn't say what's happening, then apologise to the customer, add sufficiently-many extra logging statements to the code, give the new code to the customer, and say that you'll fix it after it happens one more time.

提交回复
热议问题