Hızlı yanıt: kod örneği
The only state that may possibly be shared between your threads is the returned by . Let's check if it's the same object.Here's a very simple test you can use to try this out yourself:This will (typically) return . Since they aren't the same object, you have no thread safety issues.I say typically because depends on the underlying that loaded the instance returned by . So, unless you're writing and using your own (or 3rd party) objects, you'll be fine.
InputStream
getResourceAsStream(String)
InputStream first = getClass().getResourceAsStream("data.bin")InputStream second = getClass().getResourceAsStream("data.bin")System.out.println(first == second);
false
getResourceAsStream
ClassLoader
Class
getClass()
ClassLoader