How to terminate a long running isolate


I am trying to understand how I shall port my Java chess engine to dart.

So I have understood that I should use Isolates and/or Futures to run my engine in parallell with the GUI but how can I force the engine to terminate the search.

In java I just set some boolean that where shared between the engine thread and the gui thread.


You should send a message to the isolate, telling it to stop. You can simply do something like:


To be clear, isolates and futures are two different things, and you use them differently.

Use an isolate when you want some code to truly run concurrently, in a separate “isolated memory heap”. An isolate is like a mini program, running separately from your main program. You send isolates messages, and you can receive messages from isolates.

Use a future when you want to be notified when a value is available later. “Later” is defined as “a future tick in the event loop”. Each isolate has its own event loop. It’s important to understand that just asking a Future to run a function doesn’t make the function run in parallel. It just puts the function onto the event loop to be run “later”.

Answered By – Seth Ladd

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *