Single threads are great, but in reality, many use cases demand a wealth of threads to execute on a large-scale data set in parallel. This has been popularized by the map/reduce pattern, published several years ago, and is still a great way to process something distinct such as multiple files, rows in a database result, and many more in parallel. Whatever the source, as long as the processing is not inter-dependent, it can be chunked and mapped—both of which Rust can make easy and free of data-race conditions.
Managing multiple threads
How to do it...
In this recipe, we'll add some more threads to do map-style data processing. Follow these steps:
- Run cargo new multiple-threads to create a new application project...