Is it possible to join the main thread from a spawned thread?

I know that you can get the current thread using thread::current(), but that gives me a Thread which I cannot use from another thread to join (as far as I have found, I hope there's a way!).

I'm working on a rendering engine which uses winit for the windows, which has a requirement of having its event loop be on the main thread (due to cross-platform constraints). I've also got another thread that runs the simulation logic (I want it decoupled from rendering, so it can go faster).

I'd like to be able to have some thread that receives and handles (e.g. prints or logs) errors and panics from the threads of the program. I've read that this is usually done in the main thread which spawns the others, which seems very reasonable. In that case you've already got JoinHandles, but in my case I don't. Is it possible to create a join handle to the main thread?

Once the main thread finishes, the program will terminate immediately, so joining the main thread from somewhere else doesn’t work.

Handling panics in the main thread (e.g. for logging) can be done by catching them. Threads that aren’t the main thread can be joined from a different thread than the one that spawned them: all you need to do is let the thread that spawned the thread send the JoinHandle somewhere else, e.g. through a channel.

I see, thank you!