【发布时间】:2015-04-01 18:48:18
【问题描述】:
在 Java 中
假设我有一个类似的代码
class A {
method A(){
synchronized(this)
{
this.B();
}
}
method B(){
//do modification stuff here
}
}
我的问题是,如果一个线程在 methodA 上工作,另一个在 methodB 上工作,那么我的同步块如何得到保护。??
【问题讨论】:
-
您的问题不清楚。请详细说明。您是在问“如果线程 2 调用 B 而线程 1 调用 A(A 调用 B)会发生什么”?
-
它没有受到保护。
标签: java multithreading concurrency