Hyunjik Bae
Hyunjik Bae

Reputation: 2959

What class is used for keyword 'synchronized'?

In C#, lock keyword is equivalent to Monitor.Enter() and Leave().

In Java, What is the equivalent one to synchronized keyword?

Upvotes: 1

Views: 62

Answers (1)

Thilo
Thilo

Reputation: 262852

The synchronized keyword makes use of JVM internals in its implementation. This is not exposed as a class.

There are additional (more powerful) synchronization primitives in the java.util.concurrent package. These do not use language keywords, but are used as classes, such as ReentrantLock. They in turn make use of sun.misc.Unsafe#park, but you are not supposed to need to know about that.

Upvotes: 6

Related Questions