Skip to content

Commit

Permalink
finish arc1
Browse files Browse the repository at this point in the history
  • Loading branch information
cyz-ing committed Jan 25, 2025
1 parent af69b06 commit 44c9aa2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions exercises/smart_pointers/arc1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ use std::thread;

fn main() {
let numbers: Vec<_> = (0..100u32).collect();
let shared_numbers = // TODO
let shared_numbers = Arc::new(numbers);// TODO
let mut joinhandles = Vec::new();

for offset in 0..8 {
let child_numbers = // TODO
let child_numbers = shared_numbers.clone();// TODO
joinhandles.push(thread::spawn(move || {
let sum: u32 = child_numbers.iter().filter(|&&n| n % 8 == offset).sum();
println!("Sum of offset {} is {}", offset, sum);
Expand Down

0 comments on commit 44c9aa2

Please sign in to comment.