python - Force thread execution on a specific CPU core -


i have 2 threads in python , want force execution of thread1 on cpu core 0 , thread2 on cpu core 1. possible? if so, how? thanks

import threading import time  #i execute thread on cpu core 0 class thread1(threading.thread):      def __init__(self):         self.running = 1;           super(thread1, self).__init__()      def run(self):         while self.running:            print "thread1"  #i execute thread on cpu core 1     class thread2(threading.thread):      def __init__(self):         self.running = 1;           super(thread2, self).__init__()      def run(self):         while self.running:            print "thread2"   if __name__ == "__main__":   thread1 = thread1()   thread1.start()    thread2 = thread2()   thread2.start()    start_time = time.time()    while (time.time() - start_time) <= 5:     print "main"    thread1.running = 0;   thread2.running = 0;   thread1.join()   thread2.join() 

as now, not possible determine on core process running.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -