First of all you jinsim is a great tool. I have played around with it for some time now and it saves me a lot of time, and I really like this lib
I have some improvement suggestions:
I found out that jinsim uses a lot of cpu time. First in the examples you stop the main thread with a:
while(true) {
}
This is not a good idea, because the loop here produces a lot of no-operations on the cpu, so the cpu load is 100%.
This can be avoid by a dead-lock (the only dead-lock I know that make sense
):
String lock = new String("lock");
synchronized(lock) {
lock.wait();
}
This does the same as the loop, but does not cost any cpu time.
After I have done this, the cpu load was still high (about 50% on my machine), so a investigated the code a bit and found the cause:
In the Receiver class the run method waits for packages you have following loop:
while(isRunning()) {
...
}
When you add the command
Thread.sleep(1);
at the end of the loop, than the cpu load is near to idle on my machine, because the thread scheduler does not process this loop too excessive.
Another minor issue is that the Request classes (e.g. NewPlayerInfoRequest) the setValue method is protected, and I use this request at the start of an race to get the starting position of each player and I have to set the player id using this method.
It would be nice if the method is public, because so I don't have to make a subclass to achieve the same behavier.