Skip to content

Commit

Permalink
fix translate mistake for 1st chapter (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fodesu authored Dec 6, 2023
1 parent 0565599 commit 68236f0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 1_Basic_of_Rust_Concurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ fn main() {

当线程在持有锁时 panic,Rust 中的 mutex 将被标记为*中毒*。当这种情况发生时,Mutex 将不再被锁定,但调用它的 `lock` 方法将导致 `Err`,以表明它已经中毒。

这是一个防止由 mutex 保护的数据处于不一致状态的机制。在我们上面的示例中,如果一个线程将在整数递增不到 100 之后崩溃,mutex 将解锁并且整数将处于一个意外的状态,它不再是 100 的倍数,这可能打破其它线程的假设。在这种情况下,自动标记 mutex 中毒,强制用户处理这种可能。
这是一个防止由 mutex 保护的数据处于不一致状态的机制。在我们上面的示例中,如果一个线程在整数递增到 100 之前崩溃,mutex 将解锁并且整数将处于一个意外的状态,它不再是 100 的倍数,这可能打破其它线程的假设。在这种情况下,自动标记 mutex 中毒,强制用户处理这种可能。

在中毒的 mutex 上调用 `lock()` 仍然可能锁定 mutex。由 `lock()` 返回的 Err 包含 `MutexGuard`,允许我们在必要时纠正不一致的状态。

Expand Down

0 comments on commit 68236f0

Please sign in to comment.