Are method parameters thread safe in Java?

前端 未结 6 1769
-上瘾入骨i
-上瘾入骨i 2020-12-14 03:24
Class Shared{    
     public void sharedMethod(Object o){
          //does something to Object
     }     
}

//this is how threads call the shared method
run(){
           


        
6条回答
  •  长情又很酷
    2020-12-14 04:07

    If you call the same method in multiple threads, and pass it the same object, that object is absolutely not safe.

提交回复
热议问题