mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Implemented Thread.join()
This commit is contained in:
parent
1fd4b8ff7a
commit
83497b1b9e
|
@ -36,7 +36,9 @@ public class TThread extends TObject implements TRunnable {
|
|||
private int priority = 0;
|
||||
private long timeSliceStart;
|
||||
private int yieldCount;
|
||||
|
||||
private final Object finishedLock = new Object();
|
||||
|
||||
|
||||
private TString name;
|
||||
TRunnable target;
|
||||
|
||||
|
@ -90,6 +92,9 @@ public class TThread extends TObject implements TRunnable {
|
|||
if (target != null) {
|
||||
target.run();
|
||||
}
|
||||
synchronized(finishedLock) {
|
||||
finishedLock.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public static TThread currentThread() {
|
||||
|
@ -99,6 +104,23 @@ public class TThread extends TObject implements TRunnable {
|
|||
public TString getName() {
|
||||
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() {
|
||||
TThread currentThread = currentThread();
|
||||
|
|
Loading…
Reference in New Issue
Block a user