板友早安
class Test{
public void test1()
{
int xx;
int 00;
..
..
}
public static void test2()
{
int xx;
int 00;
..
..
}
}
我们都知道一个 thread safe 的程式都是尽量宣告local不要static
第一个method假设有两条 thread,运行的变量都存在自己thread的内存。
那第二个method呢? 他是属于 class 的 method 不是物件的,但里面又是区域变量
假设有两个物件,同时呼叫static的method,里面是区域变量,是各自属于thread的
内存吗? 还是因为是static的,所有都是同属内存,里面的运算内容会影响到呢?
谢谢指教