#0213 · 方法
并发 bug 画时序图
怀疑是并发问题。请把两个线程(或请求)的执行步骤并排写成时序表,找出它们读写同一份数据的地方,构造一种会出错的交错顺序。然后说明用什么办法让这个顺序必然出现,以便复现,最后再谈怎么加锁或改设计。
This looks like a race. Lay out the steps of two threads (or requests) side by side as a timeline, find where they read and write the same data, and build one interleaving that breaks. Then explain how to force that order so the bug reproduces, and only after that discuss locking or a redesign.
小杜
已贴 1,040 张上墙共收到 0 个章