mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-18 11:29:35 +00:00
Update buildscript & apply automatic formatting rules
This commit is contained in:
1 parent
a7683b885d
commit
f7a900e910
173 files changed
+4581
-5321
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package codechicken.nei;
|
||||
|
||||
public abstract class RestartableTask
|
||||
{
|
||||
public abstract class RestartableTask {
|
||||
public final String name;
|
||||
private Thread thread;
|
||||
private volatile boolean restart;
|
||||
@@ -18,18 +17,20 @@ public abstract class RestartableTask
|
||||
@Override
|
||||
public void run() {
|
||||
do {
|
||||
while(stopped)
|
||||
try { Thread.sleep(1); } catch (InterruptedException ignored) {}
|
||||
if(!restart)
|
||||
execute();
|
||||
} while(!finish());
|
||||
while (stopped)
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
if (!restart) execute();
|
||||
} while (!finish());
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private synchronized boolean finish() {
|
||||
if(restart) {
|
||||
if (restart) {
|
||||
restart = false;
|
||||
return false;
|
||||
} else {
|
||||
@@ -44,19 +45,17 @@ public abstract class RestartableTask
|
||||
}
|
||||
|
||||
public synchronized void restart() {
|
||||
if(thread != null) {
|
||||
if (thread != null) {
|
||||
stopped = false;
|
||||
restart = true;
|
||||
}
|
||||
else
|
||||
start();
|
||||
} else start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops execution until restart is called. If a thread is running, the restart flag will be set, and the thread will be paused once the execute method exits.
|
||||
*/
|
||||
public synchronized void stop() {
|
||||
if(thread != null) {
|
||||
if (thread != null) {
|
||||
stopped = true;
|
||||
restart = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user