It depends. There are ways in which it can be safe for streaming.
Firstly, if any argument that is passed to the method is not thread safe, and your method uses it in a multithreaded way without proper synchronization, it is not thread safe. For instance,
// HashMap is not thread safe public void foo(String key, HashMap<String,String> map) { String value = map.get(key); if (value == null) { map.put(key, "new value"); } }
Another possibility is that if any object created in the method avoids the method. Consider the following:
public void foo() { Map map = ...;
If there are other threads waiting in this queue and starting to use the map object, then the map object is shielded and is subject to the same thread safety problems.
sjlee source share