I refactor the EventQueue in KEmulator, then test on some games.
when running MI3 and Gangstar, the CPU reached 100% utilization.
and after testing, i got my answer, cause of Thread.yIEld() in run() with a while(true) circle.
Soi made a test, preReplace all the Thread.yIEld() with Thread.sleep(1)in game loading. this time, everything goes good. the MI3 got a lower10% CPU utilization in average.
sleep() will let your thread do nothing for a certain amount oftime. Basically, your thread can’t do anything until it is donesleeping.yIEld() will cause your thread to voluntarily letother threads in your program run. If no other threads are ready torun, then your thread will continue.Thread.yield() will help your thread give time to otherthreads, but when other threads are free or yIEld()ing will still takeup 100% of the CPU. Otherwise, Thread.sleep() is the only way to forcethe CPU getting a rest.
=======================
May be there is a same case in Mobile development.
Insome handset, when the game reaches the memory limit, the key eventswill cause an obviously delay. In Realfootball team last year, i foundout that calling more Thread.yIEld()(two or three) in the run() circlecan solve the problem.
Maybe one Thread.sleep(1) did the job here.