Ane*_*pal 1 java hashmap tostring thread-safety
我有以下代码:
public Hashmap<String,String> tempmap = new HashMap<String,String>();
Run Code Online (Sandbox Code Playgroud)
和一个类功能:
void f1(){
synchronized(onClassVariable1){
....Some code onClassVariable1...
String tempString = tempMap.toString();
... Some work onClassVarible1 and tempString ...
}
}
Run Code Online (Sandbox Code Playgroud)
多线程通过此类的对象调用此函数f1.
这个函数是线程安全的吗?
| 归档时间: |
|
| 查看次数: |
673 次 |
| 最近记录: |