Could someone provide a layman definition and use case?
有人可以提供外行定义和用例吗?
2 个解决方案
#1
21
"Blocking" means that the caller waits until the callee finishes its processing. For instance, a "blocking read" from a socket waits until there is data to return; a "non-blocking" read does not, it just returns an indication (usually a count) of whether there was something read.
“阻塞”意味着呼叫者等待被叫者完成其处理。例如,来自套接字的“阻塞读取”等待直到有数据要返回; “非阻塞”读取不会,它只返回是否有读取的指示(通常是计数)。
You hear the term mostly around APIs that access resources that don't necessarily require CPU attention -- I/O, for instance. You also hear it in multi-threading: A call from Thread A to Thread B might be designed to "block" (hold up Thread A) until Thread B achieves the relevant state to process or at least accept the request. (The most obvious example there being "join", which usually means "I, Thread A, want to wait until Thread B has terminated" -- you use that when exiting a multi-threaded program.)
您会听到这个术语主要围绕访问不一定需要CPU注意的资源的API - 例如I / O.您还可以在多线程中听到它:从线程A到线程B的调用可能被设计为“阻塞”(保持线程A),直到线程B达到相关状态来处理或至少接受请求。 (最明显的例子是“join”,通常意味着“我,线程A,想等到线程B终止” - 你在退出多线程程序时使用它。)
#2
3
In simple words: If you call a function that stops the program from continuing to run until the user has performed some action (or some other action that your program is not controlling), this call is called a blocking call.
简单来说:如果调用一个函数来阻止程序继续运行,直到用户执行某些操作(或程序未控制的其他操作),则此调用称为阻塞调用。
#1
21
"Blocking" means that the caller waits until the callee finishes its processing. For instance, a "blocking read" from a socket waits until there is data to return; a "non-blocking" read does not, it just returns an indication (usually a count) of whether there was something read.
“阻塞”意味着呼叫者等待被叫者完成其处理。例如,来自套接字的“阻塞读取”等待直到有数据要返回; “非阻塞”读取不会,它只返回是否有读取的指示(通常是计数)。
You hear the term mostly around APIs that access resources that don't necessarily require CPU attention -- I/O, for instance. You also hear it in multi-threading: A call from Thread A to Thread B might be designed to "block" (hold up Thread A) until Thread B achieves the relevant state to process or at least accept the request. (The most obvious example there being "join", which usually means "I, Thread A, want to wait until Thread B has terminated" -- you use that when exiting a multi-threaded program.)
您会听到这个术语主要围绕访问不一定需要CPU注意的资源的API - 例如I / O.您还可以在多线程中听到它:从线程A到线程B的调用可能被设计为“阻塞”(保持线程A),直到线程B达到相关状态来处理或至少接受请求。 (最明显的例子是“join”,通常意味着“我,线程A,想等到线程B终止” - 你在退出多线程程序时使用它。)
#2
3
In simple words: If you call a function that stops the program from continuing to run until the user has performed some action (or some other action that your program is not controlling), this call is called a blocking call.
简单来说:如果调用一个函数来阻止程序继续运行,直到用户执行某些操作(或程序未控制的其他操作),则此调用称为阻塞调用。