Skip to content
tezvyn:

What is a Dart Isolate and how does it differ from threads?

Source: dart.devHardHow cards are made

What is a Dart Isolate and how does it differ from threads?

Tests Dart's shared-nothing concurrency model. Define an isolate as an independent heap plus event loop, contrast it with shared-memory threads, and explain UI isolate communication via async message ports.

What's really being asked

This question tests whether you understand why Dart chose a shared-nothing concurrency model instead of traditional threads, and how the event loop architecture scales across CPU cores without introducing data races or mutable shared state.

The full answer

First, define an isolate as an independent unit of concurrency that contains its own memory heap, event loop, and garbage collector; all Dart code runs inside an isolate. Second, contrast isolates with traditional OS threads by emphasizing that threads share mutable memory and require locks, while isolates share nothing and communicate only through asynchronous message passing. Third, explain that each isolate has its own event loop handling microtasks and events, which keeps the single-threaded semantics within each isolate. Fourth, describe inter-isolate communication: the main UI isolate spawns a background isolate and they exchange data via SendPort and ReceivePort, with messages being copied rather than shared, ensuring the main isolate remains responsive.

The mistakes people make

A major red flag is referring to isolates as Dart threads or implying they share variables or memory; this signals a fundamental misunderstanding of the concurrency model. Another mistake is omitting the event loop entirely and treating isolates as purely parallel processes without explaining how async scheduling works inside each one. Candidates also err by suggesting isolates communicate through shared global state or callbacks rather than explicit message ports.

What usually comes next

An interviewer might ask how compute or Isolate.run simplifies spawning workers, what the performance cost of message serialization is for large objects, or how isolate groups affect memory overhead. They might also probe web limitations, asking why isolates behave differently when compiled to JavaScript.

A concrete example

Suppose the main UI isolate needs to parse a ten megabyte JSON file without dropping frames. The main isolate calls Isolate.run and passes the raw string. The background isolate receives the message through its ReceivePort, parses the JSON on its own event loop, and sends the resulting object graph back via SendPort. The main isolate listens on its ReceivePort and updates the UI when the message arrives, all without shared memory or locks.

Interview question

Unlike traditional OS threads, why do Dart isolates never require locks when accessing data from another isolate?

  • a.Because isolates share memory through isolate groups and rely on copy-on-write semantics for safety
  • b.Because a single global event loop serializes variable access across every running isolate
  • c.Because each isolate owns an independent heap and communicates by copying messages through async portsCorrect
  • d.Because the Dart VM schedules all isolates on a single OS thread and interleaves their execution
Why?

Isolates maintain independent heaps and share nothing, so they communicate by copying messages through async ports rather than using locks. Distractor A confuses the single-threaded semantics within one isolate with running all isolates on a single OS thread.

Just read this? Test yourself on what you have been reading.

Read the original → dart.dev

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on dart — each one lists the topics its interview covers.

See open roles