The ray-tracing example is a good showcase for what can be done with multithreading, but is a bit hard to grok, especially if you're interested in the fundamentals. The raytracing example uses Rayon, has an entire pool implementation, spawns multiple workers, etc.
A new, minimal and boring example of multithreading which spawns a single worker.
None that I can think of!
There's a much longer explainer post about the internals of what's going on which is still largely accurate today, but for a smaller example it's probably not a bad idea as well! It's unfortunately all still a bit rough around the edges with all the gotchas to get it up and running from scratch, but do you have an idea of what a small example you'd like to see is?
For me, a good example would highlight exactly what rough edges and gotchas exist even for a minimal use-case. Something purely illustrative, like executing a loop with enough iterations that it would freeze up a UI thread for a few seconds, after which it writes some value that can be accessed by the UI thread.
Yes, this would be fantastic if possible.
Seconded. Computing a layout iterativly off-mainthread and updating the screen with the result in every callback to request_animation_frame is also my main use case.
Most helpful comment
For me, a good example would highlight exactly what rough edges and gotchas exist even for a minimal use-case. Something purely illustrative, like executing a loop with enough iterations that it would freeze up a UI thread for a few seconds, after which it writes some value that can be accessed by the UI thread.