This file contains 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
extern crate rand; | |
use std::sync::mpsc::channel; | |
use std::thread; | |
fn main() | |
{ | |
let (tx,rx)=channel(); | |
thread::spawn(move|| |
This file contains 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
struct Test | |
{ | |
x:i32, | |
y:i32, | |
z:i32, | |
} | |
fn main() | |
{ | |
let t=Test{x:1,y:2,z:3}; |
This file contains 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
struct Test | |
{ | |
x:i32, | |
y:i32, | |
z:i32, | |
} | |
fn main() | |
{ | |
let t=Test{x:1,y:2,z:3}; |
This file contains 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
import java.util.*; | |
public class AsyncPrinter extends Thread | |
{ | |
private Queue<String> queue; | |
public AsyncPrinter() | |
{ | |
this.queue=new LinkedList<>(); | |
this.setDaemon(true); |
This file contains 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
fn main() | |
{ | |
for t in (0..8).map(|n|std::thread::spawn(move|| | |
{ | |
println!("thread({})",n); | |
})).collect::<Vec<std::thread::JoinHandle<_>>>() | |
{ | |
println!("join({:?})",t.join().unwrap()); | |
} | |
} |
This file contains 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
extern crate sctp; | |
use std::io::{stdout,stdin,Write}; | |
use sctp::SctpStream; | |
fn main() | |
{ | |
let mut buf = String::new(); | |
let mut output = stdout(); | |
let mut input = stdin(); |
This file contains 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
extern crate sctp; | |
use sctp::SctpEndpoint; | |
fn main() | |
{ | |
let mut buf : Vec<u8> = Vec::new(); | |
let endpoint = SctpEndpoint::bind("localhost:1337").unwrap(); | |
println!("Meow."); |
This file contains 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
#[derive(Debug)] | |
struct Data | |
{ | |
data: [u8;4], | |
} | |
fn main() | |
{ | |
println!("Meow."); |
This file contains 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::fmt::Debug; | |
use std::ops::{Deref,DerefMut}; | |
#[derive(Debug)] | |
struct Data<T> | |
{ | |
data: T, | |
} | |
impl<T> Data<T> |
This file contains 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
extern crate threadpool; | |
use threadpool::ThreadPool; | |
use std::sync::mpsc::channel; | |
use std::sync::{Arc,RwLock}; | |
const NUM_PRIMES: u64 = 100; | |
const NUM_THREADS: usize = 3; | |
fn main() |