I needed a way to spawn multiple threads, have them monitored, and restarted if an error occured. I came up with the following.
This snippet is from a larger program, so if there is a problem please let me know. This is for command line and tested on Linux (well, the larger program).