最好的方法是什么,跳出循环,当有多个线程吗?
What is the best way to jump out of a loop when there are multiple threads?
执行跳出循环后,我们假设实例状态是下面两个值之一。
Once the execution is out of the loop, let's assume that the instance state is one of two values.
如何才能跳出这个循环?
Which means, next time through the loop, that's going to pop out and return an answer.
循环会跳出并返回这个答案,如果不相等的话。
Remember last time, we wrote this simple piece of code to print out even or odd. If, you know, x, 1 it was in fact, even or odd. So let me show you what a flow chart for that would look like, because I want to make a comparison point here.
这就像这里有一些脚蹼一样,首先进行测试,然后把球这样放来让ANS加,然后回来继续测试,最终跳出循环然后打印答案。
And then I run a loop in which I read something in, I check to see if it's the right type, if it is, I change that variable to say it's now the correct type, which means the next time through the loop, I'm going to say I'm all set and I'm going to bounce out.
因为我还没输入,然后我运行一个循环,循环内部我输入一些东西,然后看看是不是正确的类型,如果是的话我改变input,Ok为真,来证明输入数是正确的类型,这就意味着下一次运行这个循环的时候,就可以跳出循环继续执行了。
应用推荐