Question: I'm running a CPU consuming process (calculate mandelbrot set) and that process takes almost 100% of the CPU (I have 8 cores on my machine). when I change the affinity to half of the cores the CPU consumption show 50% or lower and that is cool but what I want to understand is how this magic is done:

**my question:**
If I change the affinity while the process is running and there are threads on disabled cores - Is it safe that I won't lose any data? how is it done?

Answer: 
Although not specifically asked, I should point out (since I load all of my cores for weeks at a time, thus have some familiarity with this subject) that Affinity, while it can be useful, is not as important as Priority. Your jobs will generally finish twice as fast at 100%, compared to 50% CPU Utilization. Set the long running tasks to Low Priority and they will still run at 100% (as long as nothing of higher priority wants to run), but it will minimize the impact on doing other light-weight tasks. Only manage Affinity if there are fan noise/thermal issues you need to address... vacuuming my PC periodically gets me more mileage in that case.
It *shouldnt* have any affect on the program. The operating system's scheduler will be notified that core is no longer available to be used. Switching a process from running state into a waiting state take microseconds, so the switch will appear instantaneous. The process will continue running on all available cores.

However, if the program was poorly written, or the compiler it was made from had some issues or bugs, the program could work improperly, or completely crash.