1. A method of thread switch tuning for optimal performance of a target program executed by a data processor, comprising: (a) loading an initial predetermined value for a thread switch control register; (b) enabling thread switching for the target program; (c) executing the target program; (d) measuring performance of the target program; (e) disabling the thread switching for the target program; (f) recording values related to the performance of the target program and corresponding value of the thread switch control register; and (g) determining whether other predetermined values of the thread switch control register have all been used: (1) if no, choosing one of the other predetermined values that have not been used for the thread switch control register and restarting from step (b); (2) if yes, choosing one of recorded values of the thread switch control register as an optimal value of the thread switch control register for the target program, based on a highest performance recorded.