本文整理了Java中sun.misc.Unsafe.monitorEnter()
方法的一些代码示例,展示了Unsafe.monitorEnter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unsafe.monitorEnter()
方法的具体详情如下:
包路径:sun.misc.Unsafe
类名称:Unsafe
方法名:monitorEnter
[英]Lock the object. It must get unlocked via #monitorExit.
[中]锁定对象。它必须通过#monitorExit解锁。
代码示例来源:origin: org.apache.cassandra/cassandra-all
public static void monitorEnterUnsafe(Object object)
{
if (unsafe != null)
unsafe.monitorEnter(object);
}
代码示例来源:origin: jsevellec/cassandra-unit
public static void monitorEnterUnsafe(Object object)
{
if (unsafe != null)
unsafe.monitorEnter(object);
}
代码示例来源:origin: org.terracotta/terracotta-ee
public static void monitorEnter(Object object, int count) {
for (int i = 0; i < count; i++) {
unsafe.monitorEnter(object);
}
}
代码示例来源:origin: org.terracotta/terracotta-l1-ee
public static void monitorEnter(Object object, int count) {
for (int i = 0; i < count; i++) {
unsafe.monitorEnter(object);
}
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server
public static void monitorEnterUnsafe(Object object)
{
if (unsafe != null)
unsafe.monitorEnter(object);
}
代码示例来源:origin: com.netflix.sstableadaptor/sstable-adaptor-cassandra
public static void monitorEnterUnsafe(Object object)
{
if (unsafe != null)
unsafe.monitorEnter(object);
}
代码示例来源:origin: com.strapdata.cassandra/cassandra-all
public static void monitorEnterUnsafe(Object object)
{
if (unsafe != null)
unsafe.monitorEnter(object);
}
代码示例来源:origin: lihengming/java-codes
public void lock(Object obj) {
unsafe.monitorEnter(obj);
}
代码示例来源:origin: com.tomitribe.tribestream/tribestream-metrics-bytecode
public static void monitorEnter(final Object o) {
UNSAFE.monitorEnter(o);
}
代码示例来源:origin: kabutz/javaspecialists
public static void synchronize(Object monitor) {
unsafe.monitorEnter(monitor);
}
代码示例来源:origin: org.terracotta/terracotta-ee
public static void monitorEnter(Object object) {
unsafe.monitorEnter(object);
}
代码示例来源:origin: org.terracotta/terracotta-l1-ee
public static void monitorEnter(Object object) {
unsafe.monitorEnter(object);
}
代码示例来源:origin: lihengming/java-codes
@Test
public void test6() throws Exception {
Object lock = new Object();
//注掉下面这行代码则抛出java.lang.IllegalMonitorStateException
unsafe.monitorEnter(lock);
lock.wait(1000);
System.out.println("Hello World");
unsafe.monitorExit(lock);
}
}
代码示例来源:origin: org.terracotta/terracotta-ee
/**
* Completely release the monitor on the given object (calling thread needs to own the monitor obviously)
*
* @return the number of monitorExit calls performed
*/
public static int releaseMonitor(Object object) {
if (object == null) { throw new NullPointerException("object is null"); }
if (!Thread.holdsLock(object)) { throw new IllegalMonitorStateException("not monitor owner"); }
// This has the side effect of inflating the monitor (see VM source). It may not be necessary on all platforms (and
// can be optimized as such if necessary).
unsafe.monitorEnter(object);
unsafe.monitorExit(object);
int count = 0;
while (Thread.holdsLock(object)) {
unsafe.monitorExit(object);
count++;
}
return count++;
}
}
代码示例来源:origin: org.terracotta/terracotta-l1-ee
/**
* Completely release the monitor on the given object (calling thread needs to own the monitor obviously)
*
* @return the number of monitorExit calls performed
*/
public static int releaseMonitor(Object object) {
if (object == null) { throw new NullPointerException("object is null"); }
if (!Thread.holdsLock(object)) { throw new IllegalMonitorStateException("not monitor owner"); }
// This has the side effect of inflating the monitor (see VM source). It may not be necessary on all platforms (and
// can be optimized as such if necessary).
unsafe.monitorEnter(object);
unsafe.monitorExit(object);
int count = 0;
while (Thread.holdsLock(object)) {
unsafe.monitorExit(object);
count++;
}
return count++;
}
}
代码示例来源:origin: org.gridgain/gridgain-core
GridCacheEntryEx<K, V> entry = locked.get(i);
UNSAFE.monitorEnter(entry);
代码示例来源:origin: org.jboss.forge/jboss-modules
return performLoadClassChecked(className, exportsOnly, resolve);
} finally {
unsafe.monitorEnter(this);
代码示例来源:origin: org.gridgain/gridgain-core
GridDhtCacheEntry<K, V> entry = entryExx(key, topVer);
UNSAFE.monitorEnter(entry);
continue;
UNSAFE.monitorEnter(entry);
代码示例来源:origin: org.gridgain/gridgain-core
unsafe.monitorEnter(entry);
内容来源于网络,如有侵权,请联系作者删除!