Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
api:thread:zh [2023/10/20 13:15]
hfsr [Thread Exception Example]
api:thread:zh [2023/10/20 13:18]
hfsr [Thread Interrupt Handler Example]
Line 323: Line 323:
 ``` ```
  
-===== Thread Interrupt Handler Example ​=====+===== 线程中断处理函数样例 ​=====
  
-This example demonstrates how you would register a function that handles soft interrupts (^c) to close file handles, release resources, etc, and then exit the whole program.+此样例演示了你该如何注册处理软中断(^c)的函数,用于关闭文件句柄、释放资源等等,然后退出整个程序。
  
 ```lua ```lua
Line 345: Line 345:
  
 thread.waitForAny({cleanup_thread,​ main_thread}) thread.waitForAny({cleanup_thread,​ main_thread})
-os.exit(0) -- closes all remaining threads+os.exit(0) -- 关闭所有剩余线程
 ``` ```
  
-Assuming the user presses ​^c to send an interrupt +假设用户按下了^c发送了一次软中断 
-Output+ 
 +输出:
 ``` ```
 main program main program