mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-23 00:24:11 -08:00
Implemented Thread.join()
This commit is contained in:
parent
1fd4b8ff7a
commit
83497b1b9e
|
@ -36,6 +36,8 @@ public class TThread extends TObject implements TRunnable {
|
||||||
private int priority = 0;
|
private int priority = 0;
|
||||||
private long timeSliceStart;
|
private long timeSliceStart;
|
||||||
private int yieldCount;
|
private int yieldCount;
|
||||||
|
private final Object finishedLock = new Object();
|
||||||
|
|
||||||
|
|
||||||
private TString name;
|
private TString name;
|
||||||
TRunnable target;
|
TRunnable target;
|
||||||
|
@ -90,6 +92,9 @@ public class TThread extends TObject implements TRunnable {
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
target.run();
|
target.run();
|
||||||
}
|
}
|
||||||
|
synchronized(finishedLock) {
|
||||||
|
finishedLock.notifyAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TThread currentThread() {
|
public static TThread currentThread() {
|
||||||
|
@ -100,6 +105,23 @@ public class TThread extends TObject implements TRunnable {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void join(long millis, int nanos) throws InterruptedException {
|
||||||
|
if (currentThread() == this) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
synchronized(finishedLock) {
|
||||||
|
finishedLock.wait(millis, nanos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void join(long millis) throws InterruptedException {
|
||||||
|
join(millis, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void join() throws InterruptedException {
|
||||||
|
join(0);
|
||||||
|
}
|
||||||
|
|
||||||
public static void yield() {
|
public static void yield() {
|
||||||
TThread currentThread = currentThread();
|
TThread currentThread = currentThread();
|
||||||
if (++currentThread.yieldCount < 30) {
|
if (++currentThread.yieldCount < 30) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user