reeeee
This commit is contained in:
parent
daff47ba0d
commit
9a0737d906
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
# VScode file
|
||||
.vscode/
|
||||
SR.code-workspace
|
||||
|
||||
# PYCharm file
|
||||
.idea/
|
||||
|
@ -16,13 +16,13 @@ class Main(mp.Process):
|
||||
def run(self):
|
||||
while self.ttt:
|
||||
print(os.getpid())
|
||||
time.sleep(1)
|
||||
time.sleep(2)
|
||||
while not(self.dev.using):
|
||||
self.dev.using = True
|
||||
print("开始调用a")
|
||||
if self.dev.dev1 != 0:
|
||||
self.aaa = self.dev.dev1
|
||||
if self.dev.bget == True:
|
||||
if self.dev.bget == False:
|
||||
print("B 没拿到")
|
||||
else:
|
||||
print("B 拿到了")
|
||||
@ -46,18 +46,18 @@ class render(mp.Process):
|
||||
def run(self):
|
||||
while self.ggg:
|
||||
print(os.getpid())
|
||||
time.sleep(1)
|
||||
time.sleep(2)
|
||||
while not(self.dev.using):
|
||||
self.dev.using = True
|
||||
if random.choice(range(0, 5, 1)) == 4:
|
||||
self.dev.dev1 = self.bbb
|
||||
print("开始调用b")
|
||||
if self.dev.aget == True:
|
||||
if self.dev.aget == False:
|
||||
print("A 没拿到")
|
||||
else:
|
||||
print("A 拿到了")
|
||||
self.dev.aget = False
|
||||
self.dev.bget = True
|
||||
# self.dev.bget = True
|
||||
self.ggg = self.dev.b
|
||||
self.dev.using = False
|
||||
print("结束调用b")
|
||||
@ -81,8 +81,9 @@ if __name__ == "__main__":
|
||||
B = render(dev)
|
||||
print(":aaa")
|
||||
A.start()
|
||||
time.sleep(1)
|
||||
B.start()
|
||||
time.sleep(3)
|
||||
time.sleep(5)
|
||||
print("gogogogogogoogogogogo")
|
||||
dev.a = False
|
||||
print("A is deadddddddddddddddddddd AAAAAAAA")
|
||||
|
48
test_threading.py
Normal file
48
test_threading.py
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
import threading
|
||||
import time
|
||||
import os
|
||||
import random
|
||||
|
||||
class Aclass(threading.Thread):
|
||||
def __init__(self, dev, ID):
|
||||
threading.Thread.__init__(self)
|
||||
self.running = True
|
||||
self.value = 0
|
||||
self.dev = dev
|
||||
self.id = ID
|
||||
print(self.id)
|
||||
|
||||
def run(self):
|
||||
while self.running:
|
||||
while self.dev.using == True:
|
||||
continue
|
||||
self.dev.using = True
|
||||
self.running = self.dev.running[self.id]
|
||||
self.dev.using = False
|
||||
print(self.id, os.getpid(), os.getppid(), self.running)
|
||||
time.sleep(1)
|
||||
|
||||
class dev():
|
||||
def __init__(self):
|
||||
self.using = False
|
||||
self.gets = {'a': False, 'b': False}
|
||||
self.running = {'a': True, 'b': True}
|
||||
|
||||
Dev = dev()
|
||||
A = Aclass(Dev, 'a')
|
||||
time.sleep(random.random())
|
||||
B = Aclass(Dev, 'b')
|
||||
A.start()
|
||||
B.start()
|
||||
print("hmmm")
|
||||
while True:
|
||||
In = input()
|
||||
if In == "stop":
|
||||
Dev.running['a'] = False
|
||||
Dev.running['b'] = False
|
||||
break
|
||||
try:
|
||||
eval(In)
|
||||
except:
|
||||
print(EnvironmentError)
|
Loading…
Reference in New Issue
Block a user