score:6
the java asynchronous i/o model is described here at an easy enough level to grasp. the basic idea is that there's an internal thread pool which retrieves completed i/o notifications from the kernel and then dispatch to other threads to perform the required actions on it.
so, in a sense, yes, it uses threads. and here's something else to consider: so does everything. every piece of software out there requires that a process, at some point, check whether a piece of i/o has completed so that it can perform follow-up tasks on it (well, it could be fire-and-forget, but that's somewhat limited for practical sues). on nodejs, famous for its asynchronous i/o, that thread is called the "event loop" (though the overall model is very different).
the point here is that there is not a correspondence of one thread per i/o operation. instead, there's a single internal thread pool that's responsible for receiving all asynchronous i/o completion events, and then taking whatever actions are required on their completion.
perhaps a better question is: does asynchronous i/o in java consume threads in proportion to the number of i/o requests being processed? no, it doesn't; it consumes a fixed number of threads. more useful question: when initiating an asynchronous i/o in java, does that block the thread that initiated the i/o? no, it does not; it returns immediately. and relevant question to the topic: does asynchronous i/o in java uses threads from the actor thread pool? no, it doesn't.
next, to the future returned by asynchronous i/o. while the i/o does not complete, no thread will be used. however, there is a thread pool assigned to the completion of that future, and, when the i/o completes, one thread from that pool will be used to perform the actions that you associate with that future's completion. once those actions are finished, the thread will be returned to that thread pool. that thread pool is probably not going to be the same as the thread pool used by the actors (though i suppose there might be a way to make it so).
score:1
tl;dr on the accepted answer: no, threads are not consumed by aysnchronous i/o, but threads are used to retrieve the i/o results from the kernel.
also, from play framework: async i/o without the thread pool and callback hell:
on evented servers, waiting for i/o is very cheap: idle requests have negligible cost, as they don’t hold up a thread.
Source: stackoverflow.com
Related Query
- Does asyncronous I/O consume threads?
- How many threads does Akka use?
- Why does Scala consume 2-3x more RAM than competitors in the Computer Language Benchmarks Game?
- Is it possible and how to have Scala par consume threads from a thread pool?
- How does scala's actor model make use of C threads and native system threads?
- Apache Kafka does not consume from api
- Scala specific -- does an immutable.Set consume significantly more memory than a mutable.Set?
- Where does Scala look for implicits?
- What does "coalgebra" mean in the context of programming?
- What does a lazy val do?
- What does `:_*` (colon underscore star) do in Scala?
- Why does the Scala compiler disallow overloaded methods with default arguments?
- Understanding what 'type' keyword does in Scala
- Why doesn't the example compile, aka how does (co-, contra-, and in-) variance work?
- What does the `#` operator mean in Scala?
- How does '20 seconds' work in Scala?
- Why does "split" on an empty string return a non-empty array?
- In Scala, what exactly does 'val a: A = _' (underscore) mean?
- Why does pattern matching in Scala not work with variables?
- What limits does scala place on the "acceptable complexity" of inferred types?
- What does param: _* mean in Scala?
- Any reason why scala does not explicitly support dependent types?
- Where does the "flatmap that s***" idiomatic expression in Scala come from?
- How does type Dynamic work and how to use it?
- Does the JVM prevent tail call optimizations?
- What does "abstract over" mean?
- Editor does not contain a main type
- What does => and () => mean in Scala
- How does HashPartitioner work?
- Why does Scala provide both multiple parameters lists and multiple parameters per list?
More Query from same tag
- GCP BigQuery dependency causes failure in spark read with error of Jackson databind dependency
- regex - match punctuation at end of word in Java/Scala String
- How to find out what implicit(s) are used in my scala code
- Infinite TTL for MongoDB collection
- Can someone explain this code?
- How to schedule an hourly job with Play Framework 2.1?
- Bug in xoring or hex-decoding code
- Block statements in anonymous Scala function
- Scala. Arguments of nested lambdas with short syntax
- How to count number of directory in S3 using spark scala?
- How to check if Scala Spray Bind actually binds to port
- How to append to a list variable in session
- Scala-Groupby Array[(String, Array[String])] by the String
- Spark, Scala and eval of string transformation expression
- how to explode a spark dataframe
- Spark - How to create a map with selective fields from a flatMap
- Unbound placeholder parameter when initializing with default value
- IntelliJ 13's compiler doesn't find errors in Play projects but the highlighter does
- Scala: SBT: mergeStrategy: deduplicate: different file contents found in the following:
- How to convert a Future[Seq[A]] to a Future that contains Seq[A]?
- Split Akka Stream Source into two
- Apache Flink: Kafka Producer in IDE execution not working as expected
- Scala macros - storing global state?
- Can we make the different transformation functions for the Spark Streaming running on different servers?
- What is correct way to implement in memory queue in Scala, that support poll(n) functionality?
- How do i enable plugins in sbt subproject build file?
- How do you enrich value classes without overhead?
- Shell scripts with Scala 2.12.12 broken?
- Redirect to referer after a POST Request
- Json argument in Spark submit