0

I have been reading few articles around Multithreading and Asynchronous programming. From what I understand, true Asynchronous tasks doesn't need a new Thread to be created. But most of the articles I have gone through for Java implement Asynchronous programming using a new Thread (Either use a Runnable or Callable interface).

So my question - Is it possible to write code in Java that truly performs tasks Asynchronous

This blog post clearly states that Asynchronous task doesn't need a new thread.

Blog1, Blog2, Blog3 claims to do tasks asynchronously but still use multithreading.

3
  • 3
    The first article you linked has very little to do with multithreading on the level of the JVM - you're talking about interrupts and register handling, which is handled usually on a C or ASM level. Java abstracts this notion away entirely, the code you write isn't concerned about it. Multithreading in Java then (whether virtual or platform threads) involves scheduling multiple units of work simultaneously. Commented Nov 6, 2023 at 16:58
  • 1
    Async just means some stuff is not done in a sequence. When you calculate the sum of two arrays respectively, you can sum up a then b, or e.g. first half of a, then b, then second half of a. This is obviously possible with one thread in Java. Async is a concept. When someone talks about threads and async, they talk about parallelism. Commented Nov 6, 2023 at 17:05
  • The "async" in the first blog post is a c# keyword. It is part of a model of concurrent computing that is supported by that language. "Threads" is a somewhat different, and arguably lower-level, model of concurrent computing that is directly supported by many operating systems. Because of the wide spread OS support for threads, you may sometimes find threads used to implement async-like features in some programming languages. Commented Nov 7, 2023 at 7:03

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.