synchronization 锁住了什么?# Java - 爪哇娇娃
I*e
1 楼
假设我有一个class:
public class A{
String s;
Integer i;
int i1;
HashMap hw;
B b;
}
public class B{
...
}
如果用
A a;
synchronized(a){
...
}
那么我所住了什么? hw的锁是否被我取得? 那hw的元素的呢? 比如说hw是从String到
String的map, 我可以改变其中一个value吗?
另外, 是否b也被锁住了?
谢谢.
public class A{
String s;
Integer i;
int i1;
HashMap hw;
B b;
}
public class B{
...
}
如果用
A a;
synchronized(a){
...
}
那么我所住了什么? hw的锁是否被我取得? 那hw的元素的呢? 比如说hw是从String到
String的map, 我可以改变其中一个value吗?
另外, 是否b也被锁住了?
谢谢.