3 ms·
They basically have to be thread safe, because they're globally accessible. If you can't control access to a call that isn't thread safe, then you can't call it
by mikeash 10y ago
They basically have to be thread safe, because they're globally accessible. If you can't control access to a call that isn't thread safe, then you can't call it safely at all if there's any code in your process that you don't control (like, say, third-party libraries, or even first-party libraries).
I think it's reasonable to assume that any documented API must at least be callable.
- lomnakkus 10y agoIndeed it must be so -- at least it would be very strange to have a thread-unsafe static method where the documentation doesn't spell out how to use it safely[1]. Even in that case it would be a weird thing to even have a thread-unsafe static method (except accidentally, of course). [1] The JDK documentation is pretty good on spelling out such caveats, IME.