わかった。だから私は2つのスレッドを実行して値をインクリメントしようとしているので、いつ停止するかがわかります。私はPythonを初めて使用するので、少し迷っています。すべてが私には正しく見えます。
import threading;
import socket;
import time;
count = 0;
class inp(threading.Thread):
def run(self):
while count < 11:
time.sleep(0.5);
print("Thread 1!");
count += 1;
class recv_oup(threading.Thread):
def run(self):
while count < 31:
time.sleep(0.5);
print("Thread 2!");
count += 1;
inp().start();
recv_oup().start();
そして、エラーはかなり長いです...
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
self.run()
File "core.py", line 9, in run
while count < 11:
UnboundLocalError: local variable 'count' referenced before assignment
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
self.run()
File "core.py", line 16, in run
while count < 31:
UnboundLocalError: local variable 'count' referenced before assignment
何が起こっているのか分かりません。私が言ったように、Pythonは初めてなので、これはすべて私にとっては厄介です。どんな助けでも大歓迎です