Crates.io | hj_thread_pool |
lib.rs | hj_thread_pool |
version | 0.1.1 |
source | src |
created_at | 2024-08-31 15:03:12.079602 |
updated_at | 2024-08-31 16:39:59.532352 |
description | A simple thread pool implementation in Rust. |
homepage | |
repository | https://github.com/HaojieZhang6848/hj_thread_pool |
max_upload_size | |
id | 1358923 |
size | 30,305 |
HjThreadPool是一个简单的线程池实现,支持指定线程池中线程数量和日志级别。
use hj_thread_pool::{HjThreadPoolCfg, HjThreadPool, HjThreadPoolLogLevel};
fn main() {
let pool = HjThreadPool::new(HjThreadPoolCfg {
num_workers: 2,
log_level: HjThreadPoolLogLevel::Debug,
});
pool.execute(|| {
for i in 0..10 {
println!("Task 1: {}", i);
std::thread::sleep(std::time::Duration::from_secs(1));
}
});
}