I have asked what "asynchronous" means a while ago for interrupts. Now I have the same question but for running shell commands and for cancelling threads.

From Bash manual

If a command is terminated by the control operator &, the shell executes the command asynchronously in a subshell.

From Operating System Concepts, by Abraham Silberschatz, et al,

A thread that is to be canceled is often referred to as the target thread. Cancellation of a target thread may occur in two different scenarios:

  1. Asynchronous cancellation. One thread immediately terminates the target thread.

  2. Deferred cancellation. The target thread periodically checks whether it should terminate, allowing it an opportunity to terminate itself in an orderly fashion.

I was wondering what "asynchronous" means in the above two cases? Does it have the same meaning in the two cases?

Do the definitions from Google apply to the above two cases?:

adjective: asynchronous

  1. (of two or more objects or events) not existing or happening at the same time.

  2. Computing, Telecommunications

    of or requiring a form of computer control timing protocol in which a specific operation begins upon receipt of an indication (signal) that the preceding operation has been completed.

Do both definitions from Google seem

  • contrary to the case of "asynchronous" operator &,

  • and unrelated to "asynchronous" cancellation of threads?

If the second definition applies to the above two cases, what are "a specific operation" and "the preceding operation" in each case?



1 Answer 1


The meaning of “asynchronous” is different in all these cases.

In the shell case, & runs a command asynchronously, meaning that the shell regains control as soon as the command starts, and the command runs in the background. The shell will process the next command, if there is one, or return control to the user or the parent process, if there isn’t.

In the thread case, asynchronous cancellation means that the thread being cancelled is stopped immediately, usually in a fashion which is controlled solely from outside the thread, i.e. from the cancelling thread. The definition you came across isn’t familiar to me; I tend to think of asynchronous cancellation as described in POSIX’s definition of the pthread_cancel function, i.e. cancellation is asynchronous because the cancellation function returns control to the caller immediately, and cancellation proceeds in parallel in the target thread.

In the first definition you found using Google, asynchronous refers to the nature of communication: asynchronous communication occurs when the parties needn’t be present simultaneously. One example of asynchronous communication is email.

The second definition you found using Google seems to refer to asynchronous programming, for example callback-driven programming. Instead of defining sequences of operations procedurally, and blocking on operations, you describe events and sequences of operations which are executed when the events occur. The asynchronous definition you quote seems to refer to sequences of operations which are executed when another sequence of operations has completed (see the ListenableFuture description for one implementation of this). Imagine you want to retrieve some information from a web site and process it; in typical procedural style, you would use something like curl to retrieve the web site data, wait for that to complete, and then process it. In asynchronous style, you would describe what you want to do with the data, then fire off the retrieval, with that description, and the processing would happen as soon as the data becomes available, while you can do something else. Here the “specific operation” would be the processing you wish to perform, and the “preceding operation” would be the data retrieval.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .