C# 8.0 in a Nutshell by Joseph Albahari
Author:Joseph Albahari
Language: eng
Format: epub
Publisher: O'Reilly Media
Published: 2020-05-12T00:00:00+00:00
static void Main() { bool done = false; ThreadStart action = () => { if (!done) { done = true; Console.WriteLine ("Done"); } }; new Thread (action).Start(); action(); }
Static fields offer another way to share data between threads:
class ThreadTest { static bool _done; // Static fields are shared between all threads // in the same application domain. static void Main() { new Thread (Go).Start(); Go(); } static void Go() { if (!_done) { _done = true; Console.WriteLine ("Done"); } } }
All three examples illustrate another key concept: that of thread safety (or rather, lack of it!). The output is actually indeterminate: it’s possible (though unlikely) that “Done” could be printed twice. If, however, we swap the order of statements in the Go method, the odds of “Done” being printed twice go up dramatically:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
NET | C & C++ Windows Programming |
SQL Server | VBA |
Visual Basic |
Deep Learning with Python by François Chollet(12585)
Hello! Python by Anthony Briggs(9922)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9799)
The Mikado Method by Ola Ellnestam Daniel Brolund(9782)
Dependency Injection in .NET by Mark Seemann(9346)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8305)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7769)
Grails in Action by Glen Smith Peter Ledbrook(7700)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7563)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7131)
Microservices with Go by Alexander Shuiskov(6893)
Practical Design Patterns for Java Developers by Miroslav Wengner(6809)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6752)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6421)
Angular Projects - Third Edition by Aristeidis Bampakos(6168)
The Art of Crafting User Stories by The Art of Crafting User Stories(5693)
NetSuite for Consultants - Second Edition by Peter Ries(5621)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5431)
Kotlin in Action by Dmitry Jemerov(5070)
