Hi,
Before explaining why that happens, let me first explain how FreePIE itself works. As you probably know, the code you write in FreePIE is executed many times (approximately a 100 times) per second. This is so that it can continuously read your inputs (keyboard, mouse, joysticks etc), process the data with your code and do whatever you 'told' it to do.
Now, your CPU can go much faster than that, which is exactly what happens in your two threads; there is nothing that limits the while loop from executing as many times as possible (taking all the available CPU resources). As you have 2 threads running continuously on a 4-core CPU, this results in 50% usage.
As you found out, that's just way too much (on a dev-build of FreePIE, 4.4GHz CPU, the keyboard.getKeyDown function is called about 770.000 times a second!).
The easiest way to work around this is to "sleep" the thread. This basically tells the CPU to not execute any code from that thread for at least x seconds. If you set it to 10 miliseconds (0.01 seconds), you'll get approximately 100 executions per second.
Code: Select all
import time
# Inside the while True loop:
time.sleep(0.01) # Wait 10 miliseconds before proceeding
That said though, why are you using threads inside FreePIE in the first place? Please be aware of thread-safety (which not all FreePIE modules might be).