import pythoncom
import wmi
import threading
import time
class Info (threading.Thread):
def __init__ (self):
threading.Thread.__init__ (self)
def run (self):
print 'In Another Thread...'
pythoncom.CoInitialize ()
try:
c = wmi.WMI ()
for i in range (5):
for process in c.Win32_Process ():
print process.ProcessId, process.Name
time.sleep (2)
finally:
pythoncom.CoUninitialize ()
if __name__ == '__main__':
print 'In Main Thread'
c = wmi.WMI ()
for process in c.Win32_Process ():
print process.ProcessId, process.Name
Info ().start ()
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240803130933255-1404888097.jpg)