简体   繁体   中英

What is Thread Safety and how const constructor and final members (Immutable class) achieve "Thread-safety" in Dart?

What is the point of writing this immutable class and normal class and how it is thread safe?

class SomeClass{
  final String name;
  
  const SomeClass(this.name); 
  
}

class SomeClass2{
  String name;
  
  SomeClass2(this.name);
}

Dart is a single thread programming language because it's been developed to compile Javascript which is also a single thread programming language so it is not about that. If we were to consider your second question it is little bit complex so you can check this for an answer .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM