c#是否有自己的java"synchronized"关键字版本?
即在java中,它可以指定为函数,对象或代码块,如下所示:
public synchronized void doImportantStuff() {
// dangerous code goes here.
}
Run Code Online (Sandbox Code Playgroud)
要么
public void doImportantStuff() {
// trivial stuff
synchronized(someLock) {
// dangerous code goes here.
}
}
Run Code Online (Sandbox Code Playgroud)