View source for Talk:Multithreading
- [View source↑]
- [History↑]
Contents
Thread title | Replies | Last modified |
---|---|---|
Reinventing wheels? | 5 | 02:47, 3 March 2019 |
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.
It's more likely a sign of the state of Java (or the author's knowledge of it) at the time the page was drafted. It looks like the original is over 10 years old.
Besides Toad, do any bots actually make use of multithreading? I've always felt the community considered it to be a "dirty" tactic.
I'd be in favour of disabling multi-threading in the rumble, or somehow only allowing a single thread to run at the same time. Otherwise there could be some very dirty tactics like starving the opponent of CPU or memory bandwidth during their turns, which is against the spirit of trying to keep the bots' processing isolated except through the robocode engine.
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page.
Return to Thread:Talk:Multithreading/Reinventing wheels?/reply (3).
I usually put the engine in debug mode if I am going to be logging a lot of data. Also, robocode does increase your processing time allowed if you do any file IO.
But debug mode disables security iirc? Then this mode is unsafe for running with arbitrary opponent. Also it seems that skipped turns has no special handling if you do IO. It just increases the max skipped turns allowed before you get disabled
Java already has nonblocking IO support, may be we should support this in robocode as well. Currently doing so requires disabling security.