1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-07-13 09:40:14 +02:00

concurrency: avoid 1.. loops (#2280)

Fixes #2060. Note that this does not change the "blocking executor"
example because on that slide it is worthwhile to sleep for 1 * 10ms on
the first iteration and so on. But we shouldn't use one-indexed
inclusive loops when the only significant feature of the loop is its
iteration count.
This commit is contained in:
Frances Wingerter
2024-08-13 14:38:22 +00:00
committed by GitHub
parent e9fce0417e
commit dfd08ebf93
6 changed files with 8 additions and 8 deletions

View File

@ -13,7 +13,7 @@ use std::thread;
fn main() {
let v = Arc::new(vec![10, 20, 30]);
let mut handles = Vec::new();
for _ in 1..5 {
for _ in 0..5 {
let v = Arc::clone(&v);
handles.push(thread::spawn(move || {
let thread_id = thread::current().id();