I really don't like repeating myself. But you can't just determine from the call site what that thing you're calling does with your closure.
So if you want to be sure, you have two options:
Inspect the entire tree of code into whatever you're using and make sure the implementation doesn't call from another thread. Make sure to repeat that process every time you update your dependencies.
1
u/[deleted] Mar 22 '21
No. It means you can’t use closures in a static initialiser which will be called during initialisation from another thread.
You can use them just fine for single threaded initialisation. The key bit the multithreaded aspect.