父线程创建多个子线程,子线程阻塞,父线程无法继续创建子线程 5C

#主进程

-*- coding: UTF-8 -*-

import Other.Thread_self as Thread_self
import peripherals.serial_io as ser
if name == "__main__":
Thread_list = []
# Test_Thread = Thread_self.Thread_Self(1, "Test_Thread", 1)
# Test_Thread.run()

serial_com1 = ser.serial_self('COM1',115200)
Serial_read_Thread = Thread_self.Thread_Serial_read(1, "Serial_read_Thread", serial_com1)
Serial_read_Thread.run()

serial_com2 = ser.serial_self('COM2',115200)
Serial_write_Thread = Thread_self.Thread_Serial_write(2, "Serial_write_Thread", serial_com2)
Serial_write_Thread.run()

GUI_peripheral_Thread = Thread_self.Thread_GUI(3, "GUI_peripheral_Thread", 2)
GUI_peripheral_Thread.run()

Server_listen_Thread = Thread_self.Thread_Server_listen(4, "Server_listen_Thread", 2)
Server_listen_Thread.run()

class Thread_Serial_read (threading.Thread): #继承父类threading.Thread
def init(self, threadID, name, obj_serial):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.obj_serial = obj_serial
def run(self): #把要执行的代码写到run函数里面 线程在创建后会直接运行run函数
print "Starting " + self.name
self.obj_serial.read()
print "Exiting " + self.name

            class serial_self():
def __init__(self, name, bout_rate):
    self.ser = serial.Serial(name, bout_rate)  # winsows系统使用com1口连接串行
def read(self):
    read_data = self.ser.read()
    Other.queue_self.From_serial_Que.put(read_data)

def write(self):
    write_data = Other.queue_self.From_server_Que.get()
    self.ser.write(write_data)

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问