share 3 4 5
parent
a80ad35b65
commit
2f79151466
@ -0,0 +1,13 @@
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
static A: [u8; 100] = [22; 100];
|
||||
|
||||
thread::spawn(|| {
|
||||
A[3];
|
||||
});
|
||||
|
||||
thread::spawn(|| {
|
||||
A[3]
|
||||
});
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
use std::thread;
|
||||
#[macro_use] extern crate lazy_static;
|
||||
|
||||
lazy_static! {
|
||||
static ref A: Vec<u32> = {
|
||||
vec![1, 2, 3]
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {
|
||||
thread::spawn(|| {
|
||||
A[1];
|
||||
});
|
||||
|
||||
thread::spawn(|| {
|
||||
A[2];
|
||||
});
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
use std::thread;
|
||||
use std::sync::{Arc};
|
||||
|
||||
fn main() {
|
||||
let a = Arc::new(vec![1, 2, 3]);
|
||||
|
||||
{
|
||||
let a = Arc::clone(&a);
|
||||
thread::spawn(move || {
|
||||
a[1];
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let a = Arc::clone(&a);
|
||||
thread::spawn(move || {
|
||||
a[1];
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue