Skip to content

Instantly share code, notes, and snippets.

@evaporei
Created February 9, 2018 15:49
Show Gist options
  • Save evaporei/61fa11b0cba8a2652d929acdc0699c96 to your computer and use it in GitHub Desktop.
Save evaporei/61fa11b0cba8a2652d929acdc0699c96 to your computer and use it in GitHub Desktop.
Threads
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