0

In this Java Threads course by Peggy Fisher (on LinkedIn) it says, asynchronous is concurrent. Is this correct or incorrect? I was watching this online course and wondered if the definition is incorrect. (I have always understood it to mean, 'not synchronized').

slide on Threads

likejudo
  • 3,396
  • 6
  • 52
  • 107

3 Answers3

2

Asynchronous means:

  • it can run concurrently "now" on a different thread on the same processor (task switching) or a thread on a different processor (parallelism) or
  • a little later but still concurrent with the piece of code that created this task and submitted it for execution or
  • it can run hours later after the calling piece of code has finished execution

The essential thing to understand is that the piece of code that created this task running on a thread does "not need" to block and wait for this task to be completed.

The task is not guaranteed to run at a specific time interval and the main thread does not need to block waiting for the completion of this task.

Let's say that Code C running on Thread M creates a Task T and submits it for asynchronous execution. Now there are two things:

  1. T runs concurrently as is specified here on a different Thread T' (same processor giving the appearance of parallelism) or a different processor - actual parallelism)
  2. T runs at some time even hours later on a different Thread T' or perhaps is picked up by the same thread M.

Both of these outcomes are possible. And they depend on what the logic implemented by your code is.

However there is a related concept that should clarify the concepts further. And that is the clarification of parallel and concurrent.

There is another post that has a schematic defining the subtle differences between "asynchrony", "concurrency" and "parallelism".

I can regurgitate the difference but there is already a post that is very succinct and the answers are clear as well.

MyStackRunnethOver
  • 4,872
  • 2
  • 28
  • 42
Khanna111
  • 3,627
  • 1
  • 23
  • 25
1

In this Java Threads course by Peggy Fisher (on LinkedIn) it says, asynchronous is concurrent.

I think that is a misreading. The actual wording is:

"Asynchronous indicates that [the task] can run concurrently"

What it is saying that asynchronous tasks can run concurrently. It doesn't say that they will run concurrently.

In particular, there are frameworks, languages, hardware where asynchronous tasks (in general) are executed on the same thread of control ... when the current activity suspends itself.

The wording is both technically correct, and a general enough to cover common uses of the term.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
0

It says, asynchronous is concurrent.

No, it doesn't. The definition in the course is written correctly. it(asynchronous task) can run concurrently.

If tasks are synchronous, each of them runs only one at a time after another.

zmag
  • 7,825
  • 12
  • 32
  • 42