Created
February 9, 2018 15:49
-
-
Save evaporei/61fa11b0cba8a2652d929acdc0699c96 to your computer and use it in GitHub Desktop.
Threads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::vec::Vec; | |
use std::thread; | |
fn main() { | |
let array = &[1..1000]; | |
let mut handlers = Vec::new(); | |
for i in 0..3 { | |
let slice = &array[(i * 250)..((i + 1) * 250)]; | |
let handler = thread::spawn(move || { | |
println!("{:?}", slice); | |
}); | |
handlers.push(handler); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment