Reinventing wheels?
From Talk:Multithreading
Jump to navigation
Jump to search
Revision as of 28 February 2019 at 07:21.
This is the thread's initial revision.
This is the thread's initial revision.
Although the sample code implemented tick synchronization between worker thread and robot thread, the use of token may not be necessary, since Java already had similar mechanism.
worker = new Thread(() -> {
try {
while (true) {
Thread.sleep(1000);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
});
call worker.interrupt()
whenever you don't need it anymore, or just wait robocode to call that method for you.