擅长:python、mysql、java
<p>您需要使用某种并行处理来工作,以及创建一种中断正在运行的线程的方法。在</p>
<p>阅读<a href="https://docs.python.org/2/library/threading.html" rel="nofollow">threading</a>并创建并启动两个<code>Thread</code>对象,每个对象对应一个方法。我要采取的总体方法是在<code>testRunning()</code>方法中读取一个布尔值,然后在<code>stopButton()</code>方法中写入它。在</p>
<pre><code>if not keepRunning:
return
</code></pre>
<p>并在每次调用<code>wiringpi2.digitalWrite()</code>之前插入它。使用带超时的<code>notify()</code>可以使<code>stopButton()</code>立即结束{<cd2>}方法,而不是延迟。在</p>
<p>最后一个棘手的部分:记住在启动线程之后<code>join()</code>你的线程。在</p>
^{pr2}$