I’m very new to Dart and stilling learning it. As I understand, Dart executes code in different isolates. An isolate could start up another isolate to execute some long-running code. For each isolate, there is a thread and some memory allocated for it. These isolates are isolated like a bunch of little VMs.
I also read from the Dart document that Dart is a single threaded language. But, think about it, each isolate has its own thread. If isolate A has thread t1 and isolate B has thread t2, t1 and t2 are not the same thread, right?
If t1 and t2 are the same thread, then t1 and t2 can’t execute code at the same time, which is ridiculous. So, t1 and t2 must be different thread.
If so, why we say Dart is a single-threaded language?
Yes and no.
"Yes" in the sense that you don’t have to worry about locks or mutexes.
"No" in the sense that you list.
Dart tries to offer some of the benefits of multi-threading with isolates while avoiding all of the issues with shared memory multi-threading.
Answered By – Kevin Moore
Answer Checked By – Mary Flores (FlutterFixes Volunteer)