Sunday, 15 May 2011

multithreading - Limiting Thread Execution Processor Cycles in Java -


I am writing a-testing framework for a competition. Participants present a bot class which is given from a given interface Matches. Then all the boats play a turn-based game. At each turn, I want to do the following:

  B for each bot: Start a thread that runs on most N cycles and beatanetfew () to complete all the threads Wait for everyone to make moves (from each bot)  

My difficulty comes in saying "the most N cycles". I can limit all the boats (up to half a second per turn) from time to time, but this means that some can get more processor cycles than others and do not allow hardening "Your bot recovers its decision Must be able to: A turn X time "requirement in competition.

As it has been said, is there any idea in this Java? I'm looking at concatenation and locking but it does not feel like the right direction. Also, it is possible to run bots in Parallel and then use time for the ban (given that the computer is not running at that time), but it would be undesirable because it will slow down the speed at which we The result can be from the game.

I will create an interface with them to bot 1 repeat your algorithm, and a simple calculation We do.

If you need a hard / CPU limit, there are not many (easy) ways to manage it in Java.

You can not remove the CPU cycle with Java, but you can measure CPU time - which is just a huge improvement using the timer of the clock.

CPU time standard package to use the current thread)

  threadmxbin tm = managementfighter .getThreadMXBean (); Tall CPU time = TM.EstContTrade CPU ();  

No comments:

Post a Comment