'Difference between Thread, Isolate and Process in Dart

What's the difference between Thread, Isolate and a Process in Dart?

As far as I know Dart is a single-threaded language, but it can spawn many isolates which don't share memories with each other and we can do the heavy lifting work on them and return the result without blocking the UI.

But what Process is for, is that a part of an Isolate? Can anyone describe above three in more detail.

And when we do asynchronous programming using Future and let's see we are doing heavy lifting in it, will that block the UI thread in case it is awaited using the await keyword.



Solution 1:[1]

A Process is a native OS (Unix, Windows, MacOS) construct, which consists of one or more threads with their own address space and execution environment. In Dart, an application consists of one or more threads, one of which is the main UI thread, while the rest are typically called Isolates.

Solution 2:[2]

In contrast to what the previous answer said, All Dart code runs in an isolate.

Actually, your understanding is correct, based on what you said in the comments.

From the docs (emphasis mine):

Within an app, all Dart code runs in an isolate. Each Dart isolate has a single thread of execution and shares no mutable objects with other isolates. To communicate with each other, isolates use message passing. Although Dart’s isolate model is built with underlying primitives such as processes and threads that the operating system provides, the Dart VM’s use of these primitives is an implementation detail that this page doesn’t discuss.

Many Dart apps use only one isolate (the main isolate), but you can create additional isolates, enabling parallel code execution on multiple processor cores.

Your question hasn't been answered yet, and it will not be answered easily, because it depends on the language implementation.

Also, your another question: "And when we do asynchronous programming using Future and let's see we are doing heavy lifting in it, will that block the UI thread in case it is awaited using the await keyword."

-> Yes, it will block the UI, unless you use another isolate.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Randal Schwartz
Solution 2 starriet