⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thread1.py

📁 Python.Tkinter编程实例代码多多学习
💻 PY
字号:
import thread, time

class Server:
    def __init__(self):
        self._dispatch = {}
        self._dispatch['a'] = self.serviceA
        self._dispatch['b'] = self.serviceB
        self._dispatch['c'] = self.serviceC
        self._dispatch['d'] = self.serviceD

    def service(self, which, qual):
        self._dispatch[which](qual)

    def serviceA(self, argin):
        thread.start_new_thread(self.engine, (argin,'A'))

    def serviceB(self, argin):
        thread.start_new_thread(self.engine, (argin,'B'))

    def serviceC(self, argin):
        thread.start_new_thread(self.engine, (argin,'C'))

    def serviceD(self, argin):
        thread.start_new_thread(self.engine, (argin,'D'))

    def engine(self, arg1, arg2):
        for i in range(500):
            print '%s%s%03d' % (arg1, arg2, i),
            time.sleep(0.0001)
        print

server = Server()

server.service('a', '88')
server.service('b', '12')
server.service('c', '44')
server.service('d', '37')

time.sleep(30.0)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -