The new thread terminates in one of the following ways

以下内容翻译的是:

 

http://man7.org/linux/man-pages/man3/pthread_create.3.html

 

The new thread terminates in one of the following ways:

       * It calls pthread_exit(3), specifying an exit status value that is
         available to another thread in the same process that calls
         pthread_join(3).

       * It returns from start_routine().  This is equivalent to calling
         pthread_exit(3) with the value supplied in the return statement.

       * It is canceled (see pthread_cancel(3)).

       * Any of the threads in the process calls exit(3), or the main thread
         performs a return from main().  This causes the termination of all
         threads in the process.

片段。

线程中断有以下几种方式:

线程中调用thread exit函数,该函数调用需要指定一个退出状态,如果有其他线程
thread join这个线程的话,这个状态值有用。

线程函数返回。这种方式等同于thread exit,exit的状态值等同于返回值。

调用thread cancel, 请求取消了这个线程。

在程序中任何地方、任何线程中调用了exit方法退出,包括在主线程main方法返回都将
中断所有线程。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
In the context of loops, both "continue" and "break" statements are used to control the flow of the loop, but they have different effects: - The "continue" statement is used to skip the current iteration of a loop and move on to the next one. When the "continue" statement is encountered in a loop, the remaining code in the loop body is skipped for the current iteration, and the loop moves on to the next iteration. The loop continues to execute until all iterations are completed. For example, let's say we have a loop that iterates over a list of numbers and we want to skip any negative numbers. We could use the "continue" statement to skip over any negative numbers and move on to the next iteration: ``` numbers = [1, -2, 3, -4, 5] for num in numbers: if num < 0: continue print(num) ``` Output: ``` 1 3 5 ``` - The "break" statement is used to terminate a loop early. When the "break" statement is encountered in a loop, the loop terminates immediately, and the program execution moves on to the next statement after the loop. For example, let's say we have a loop that iterates over a list of numbers and we want to stop the loop as soon as we find a negative number. We could use the "break" statement to terminate the loop early: ``` numbers = [1, -2, 3, -4, 5] for num in numbers: if num < 0: break print(num) ``` Output: ``` 1 ``` In summary, the "continue" statement skips the current iteration of a loop and moves on to the next one, while the "break" statement terminates the loop early and moves on to the next statement after the loop.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值