什么术语;堵"编程是什么意思? [英] What does the term "blocking" mean in programming?

查看:192
本文介绍了什么术语;堵"编程是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能提供一个门外汉定义和使用情况?

Could someone provide a layman definition and use case?

推荐答案

堵是指主叫等待,直到被叫方完成其处理。例如,从一个插座阻塞读等待,直到有数据返回;一个非阻塞读不,它只是返回是否有东西读的指示(通常是一个计数)。

"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.

您听到这个词大多是围绕在访问该不一定需要CPU注意力资源的API - I / O,例如。你也听到它在多线程:从线程A到B线程调用可能被设计成块(托起线程A),直到线程B达到国家有关处理,或者至少接受请求。 (还有最明显的例子是加盟,这通常意味着我,线程A,要等到线程B已终止 - 您使用退出多线程程序时。)

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.)

这篇关于什么术语;堵"编程是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆