"java: is exception class thread-safe?" Code Answer


note that initcause() is synchronized and setstacktrace() copies its parameter and then does a single assignment.

so exception actually does seem to be implemented with thread-safety in mind. still, i'd be wary of any design where exceptions are routinely passed around between threads (i.e. for any reason other than handling a very serious error condition). it just feels wrong.

By lemonmojo on June 7 2022

Answers related to “java: is exception class thread-safe?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.