An implementation of a thread pool that is similar to ThreadPoolExecutor
in java.
Install this library using cargo
,
cargo install jtp
Or add this to your Cargo.toml
:
[dependencies]
jtp = "0.1.0"
And use this library:
```rust // Creates a thread pool. let mut threadpool = ThreadPoolBuilder::default() .setcorepoolsize(6) // Sets the number of core threads. .setmaxpoolsize(10) // Sets the maximum number of threads. .setchannelcapacity(100) // Sets the capacity of the task queue. .setrejectedhaskhandler(RejectedTaskHandler::Abort) .build() .unwrap();
for _ in 0..50 { // Execute a task in the future. thread_pool.execute(|| { println!("Hello World"); }); } ```
Apache License, Version 2.0, LICENSE-APACHE