You've already forked comprehensive-rust
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:
committed by
GitHub
parent
e9fce0417e
commit
dfd08ebf93
@ -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();
|
||||
|
Reference in New Issue
Block a user