# windows-threading
Safe access to the Windows thread pool, including scoped tasks that borrow local data.
Use it for CPU or blocking work that does not need a dedicated thread.
- 📦 [crates.io](https://crates.io/crates/windows-threading)
- 📖 [docs.rs](https://docs.rs/windows-threading)
- 🧩 [Samples](https://github.com/microsoft/windows-rs/tree/master/crates/samples/threading)
- 📁 [Source](https://github.com/microsoft/windows-rs/tree/master/crates/libs/threading)
## Get started
```toml
[dependencies]
windows-threading = "0.101"
```
```rust,no_run
let total = std::sync::Mutex::new(0);
});
assert_eq!(*total.lock().unwrap(), 45);
```
## Choose lifetime and concurrency
`submit` runs a `Send + 'static` closure on the default pool without waiting. `for_each` waits for
all items to finish, so its closure can borrow local data.
Use `Pool` for a private pool and `Pool::scope` for borrowing tasks. Dropping a pool waits for its
work to finish. Avoid waiting on tasks queued to the same constrained pool, and handle expected
failures inside callbacks rather than panicking.
Use a dedicated thread for work requiring a stable thread identity or apartment.
The [pool sample](https://github.com/microsoft/windows-rs/tree/master/crates/samples/threading/pool)
shows scoped work and thread limits.