Throwing an exception not only unwinds the test but also signals an error.
抛出异常不仅要展开测试,还将报告错误。
If the caller won't be able to handle the exception in a meaningful way, consider throwing an unchecked (run-time) exception.
如果调用者不能以有意义的方式处理这个异常,那么考虑抛出一个未检查的(运行时)异常。
Instead of throwing an exception when the queue is empty, the reader thread now blocks itself on the condition variable.
当队列是空的时候,读线程现在并不抛出异常,而是在条件变量上阻塞自身。
If I do this, try and get the 10th element of a list that's only eight long. I get what looks like an error, but it's actually throwing an exception.
如果我来这么做,试着去取长度为8的列表的第十个元素,我貌似能得到一个错误。
应用推荐