pub fn new(size: usize) -> ThreadPool {
        assert!(size > 0);

        let mut workers = Vec::with_capacity(size);
        let (sender, receiver) = mpsc::channel();
        let receiver = Arc::new(Mutex::new(receiver));
        for id in 1..=size {
            workers.push(Worker::new(id, receiver.clone()));
        }

        ThreadPool { workers, sender }
    }
/// Create a new ThreadPool.
///
/// The size is the number of threads in the pool.
///
/// # Panics
///
/// The `new` function will panic if the size is zero.
Create a new ThreadPool.
The size is the number of threads in the pool.
Create a new ThreadPool . The size is the number of threads in the pool .
pub fn new(size: usize) -> ThreadPool {
        assert!(size > 0);
        let mut workers = Vec::with_capacity(size);
        let (sender, receiver) = mpsc::channel();
        let receiver = Arc::new(Mutex::new(receiver));
        for id in 1..=size {
            workers.push(Worker::new(id, receiver.clone()));
        }
        ThreadPool { workers, sender }
    }
pub fn new ( size : usize ) -> ThreadPool { assert ! ( size 0 ) ; let mut workers = Vec :: with_capacity ( size ) ; let ( sender , receiver ) = mpsc :: channel ( ) ; let receiver = Arc :: new ( Mutex :: new ( receiver ) ) ; for id in 1 ..= size { workers . push ( Worker :: new ( id , receiver . clone ( ) ) ) ; } ThreadPool { workers , sender } }
Create a new ThreadPool.
Create a new ThreadPool .
size
usize
size
usize
panics
The `new` function will panic if the size is zero.
The ` new ` function will panic if the size is zero .