2

Is it possible to control the proportional execution time of a thread in python. For example, I have three functions F1, F2 and F3 in my program. I am calling each function with using start_new_thread in python. I want F2 thread to execute 70 percent of time while F1 and F3 should share rest of 30 percent. Is there a way to explicitly control these timings.

4

1 回答 1

0

您可以使用优先级队列和时间片创建调度程序。不确定 Python 中的具体细节,但概念是相同的:创建一个接受线程的调度程序类,将线程添加到具有给定优先级的优先级队列中,然后在指定的时间段过去后使线程休眠。您可以根据当前线程优先级定制时间片。

这类似于操作系统如何调度进程线程。

于 2013-06-03T13:46:39.667 回答