📄 aemonitor.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: AEMonitor.java
package org.gudy.azureus2.core3.util;
import java.util.Collections;
import java.util.Map;
// Referenced classes of package org.gudy.azureus2.core3.util:
// AEMonSem, Debug
public class AEMonitor extends AEMonSem
{
private int dont_wait;
private int nests;
private int total_reserve;
private int total_release;
protected Thread owner;
protected Thread last_waiter;
public AEMonitor(String _name)
{
super(_name, true);
dont_wait = 1;
nests = 0;
total_reserve = 0;
total_release = 1;
}
public void enter()
{
if (DEBUG)
debugEntry();
Thread current_thread = Thread.currentThread();
synchronized (this)
{
entry_count++;
if (owner == current_thread)
{
nests++;
} else
{
if (dont_wait == 0)
{
try
{
waiting++;
last_waiter = current_thread;
if (waiting <= 1);
int spurious_count = 0;
do
{
wait();
if (total_reserve != total_release)
break;
if (++spurious_count > 1024)
{
waiting--;
Debug.out("AEMonitor: spurious wakeup limit exceeded");
throw new Throwable("die die die");
}
} while (true);
total_reserve++;
}
catch (Throwable e)
{
waiting--;
owner = current_thread;
Debug.out("**** monitor interrupted ****");
throw new RuntimeException("AEMonitor:interrupted");
}
finally
{
last_waiter = null;
throw exception;
}
last_waiter = null;
} else
{
total_reserve++;
dont_wait--;
}
owner = current_thread;
}
}
}
public boolean enter(int max_millis)
{
if (DEBUG)
debugEntry();
Thread current_thread = Thread.currentThread();
AEMonitor aemonitor = this;
JVM INSTR monitorenter ;
entry_count++;
if (owner == current_thread)
{
nests++;
break MISSING_BLOCK_LABEL_199;
}
if (dont_wait != 0)
break MISSING_BLOCK_LABEL_174;
boolean flag;
waiting++;
last_waiter = current_thread;
wait(max_millis);
if (total_reserve != total_release)
break MISSING_BLOCK_LABEL_111;
waiting--;
flag = false;
last_waiter = null;
return flag;
Exception exception;
try
{
total_reserve++;
}
catch (Throwable e)
{
waiting--;
owner = current_thread;
Debug.out("**** monitor interrupted ****");
throw new RuntimeException("AEMonitor:interrupted");
}
finally
{
last_waiter = null;
}
last_waiter = null;
if (false)
throw exception;
break MISSING_BLOCK_LABEL_194;
total_reserve++;
dont_wait--;
owner = current_thread;
aemonitor;
JVM INSTR monitorexit ;
goto _L1
Exception exception1;
exception1;
throw exception1;
_L1:
return true;
}
public void exit()
{
synchronized (this)
{
if (nests > 0)
{
if (DEBUG && owner != Thread.currentThread())
Debug.out("nested exit but current thread not owner");
nests--;
} else
{
owner = null;
total_release++;
if (waiting != 0)
{
waiting--;
notify();
} else
{
dont_wait++;
if (dont_wait > 1)
Debug.out((new StringBuilder()).append("**** AEMonitor '").append(name).append("': multiple exit detected").toString());
}
}
}
if (DEBUG)
debugExit();
break MISSING_BLOCK_LABEL_168;
Exception exception1;
exception1;
if (DEBUG)
debugExit();
throw exception1;
}
public boolean isHeld()
{
return owner == Thread.currentThread();
}
public boolean hasWaiters()
{
AEMonitor aemonitor = this;
JVM INSTR monitorenter ;
return waiting > 0;
Exception exception;
exception;
throw exception;
}
public static Map getSynchronisedMap(Map m)
{
return Collections.synchronizedMap(m);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -