首页 \ 问答 \ 如果没有IO线程来处理异步结果,会发生什么情况?(What happens if there are no IO threads to handle async result?)

如果没有IO线程来处理异步结果,会发生什么情况?(What happens if there are no IO threads to handle async result?)

我想知道当没有IO线程处理异步调用的结果时会发生什么。

假设你做了一个异步web请求(在服务器应用程序中,所有异步代码都由线程池处理)。 操作系统会发出信号,告诉您何时有结果,何时需要IO线程来读取套接字中的字节。 如果没有IO线程可用,因为这些线程都在使用中(全部含义由线程池设置的最大值)会发生什么情况? 有信号可以等待,直到有线程可用的队列吗? 还是信号只是闻所未闻? 如果后者发生,等待等待的代码会发生什么?


I'm wondering what happens when there are no IO threads to handle the result of an async call.

Say you make an async web request (in a server application so all async code is handeled by the thread pool). The OS will signal when there is a result for you and when it does you'll need an IO thread to read the bytes from the socket. If there are no IO threads available because that are all in use (all meaning up to the max set by the thread pool) what happens? Is there a queue where the signal can wait until there is a thread available? Or does the signal just go unheard? If the latter happens, what happens to the code waiting on the await?


原文:https://stackoverflow.com/questions/39053762
更新时间:2023-07-26 14:07

最满意答案

你也需要转换第二个参数:它是一个int参数,但你的数字是长的。 显然编译器可以在某些情况下(例如这个)解决它,但是一旦你开始提供类型提示,你就应该完成消除歧义。

user> (Math/scalb (double 21) (int -63))
2.2768245622195593E-18

You need to convert the second argument too: it's an int argument, but your numbers are longs. Obviously the compiler could figure it out in some cases (such as this one), but once you start providing typehints you're expected to finish disambiguating.

user> (Math/scalb (double 21) (int -63))
2.2768245622195593E-18

相关问答

更多
  • 你也需要转换第二个参数:它是一个int参数,但你的数字是长的。 显然编译器可以在某些情况下(例如这个)解决它,但是一旦你开始提供类型提示,你就应该完成消除歧义。 user> (Math/scalb (double 21) (int -63)) 2.2768245622195593E-18 You need to convert the second argument too: it's an int argument, but your numbers are longs. Obviously the c ...
  • 从关于Clojure讨论组的讨论中 ,您似乎遇到了Rich Hickey所做的设计决定。 具体来说,因为BigDecimal没有签名BigDecimal(Long long)的构造函数(编辑:因此编译器必须在int和long构造函数之间进行选择 - 请参阅下面有关为什么使用Integer工作的讨论的注释),编译器将不要试图“猜测”你的意思,并明确地失败。 底线是Java端的特定类型要求,为了有正确和非脆弱的代码,需要显式装箱。 - Rich Hickey 请注意,根据本文档 ,文字被解析为基元,而不是“盒装 ...
  • cast不会做你认为它只是确保第二个参数是指定类并返回它(第二个参数,而不是类)或抛出异常。 您需要添加类型提示,但不能直接将其添加到nil : => (String. nil) CompilerException java.lang.IllegalArgumentException: More than one matching method found: java.lang.String 这里我有一个例外,因为nil匹配太多的重载并且编译器不知道要选择哪个。 => (let [^String cnil ...
  • 您的名称空间声明是错误的 (ns bulbs.neo4jserver.client (:use [bulbs.base.client :only [ClientProtocol]])) 协议功能是正常的Clojure功能,必须这样处理。 因此,您必须将它们包含在:only子句中。 (ns bulbs.neo4jserver.client (:use [bulbs.base.client :only [create-edge ClientProtocol]])) Your namespace de ...
  • 是的,它们是重载方法,因为它们具有相同的名称但参数类型不同。 apomeme的答案给出了更多细节。 回答第二个问题: 你的电话eJava(111, "word", 222)不是含糊不清的,也不是汇编错误。 它匹配第一个方法: eJava(int age, String name, double duration) 。 它不能匹配第二种方法,因为它的第三个参数是一个字节,并且int文本不能隐式转换为一个字节。 除非您明确施放它们,否则不允许这种缩小转换。 但是,如果第二种方法是 float eJava(dou ...
  • 你错过了一个参数。 reify实现的每个方法的第一个参数是对象本身(与defrecord / deftype )。 所以,试试这个: (defn -create-message-factory [] (reify quickfix.MessageFactory (create [this beginString msgType] nil) (create [this beginString msgType correspondingFieldID] nil) ...
  • 有一种机制可以与gen-class并允许覆盖相同的arity重载方法。 除了前缀和方法名称之外,我们还可以定义包含参数类型的名称的变量/函数。 要覆盖像foo(String s, Object o)这样的方法foo(String s, Object o)我们可以定义一个名为-foo-String-Object的var。 代码将在回-foo之前查找因此命名的var。 至少在一个Clojure邮件列表线程中记录了这一点。 在实践中,这意味着您可以编写如下代码: (defn interop-compare [th ...
  • 以下是一些基本的演示示例: (import 'javax.measure.unit.SI) (import 'javax.measure.Measure) ; Integer Value ; will call: ; public static Measure valueOf (Measure/valueOf (Integer. 2) SI/KILOGRAM) ; Long value ; will call: ...
  • 据我所知,这种可见性定义为:private var的meta :private标志。 所以这两个表达式是相同的: (defn ^:private foo [] "bar") (defn- foo [] "bar") 所以我认为你只能控制整个var的可见性。 我可以建议为公共和私人空间使用不同的函数名称。 即公共的func-name和私有的func-name- 。 As I know this visibility is defined by :private flag in var's meta. So ...
  • 我刚用你的代码测试过。 getValue()实际上返回所选项目的索引(仅当您设置显示的值时)。 所有你需要做的就是解析字符串,你会得到你想要的。 String[] nums = {"1","1.5","2","2.5","3","3.5","4","4.5","5","5.5","6","6.5","7","7.5","8","8.5","9"}; int index = listeningScorenp.getValue(); String val = nums[index]; float selecte ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。