C# Essentials by Albahari Ben Drayton Peter Merrill Brad & Peter Drayton & Brad Merrill
Author:Albahari, Ben, Drayton, Peter, Merrill, Brad & Peter Drayton & Brad Merrill [Ben Albahari]
Language: eng
Format: epub
Tags: COMPUTERS / Programming Languages / C#
ISBN: 9781449390839
Publisher: O'Reilly Media
Published: 2010-03-04T16:00:00+00:00
Threading
A C# application runs in one or more threads that effectively execute in parallel within the same application. Here is a simple multithreaded application:
using System; using System.Threading; class ThreadTest { static void Main( ) { Thread t = new Thread(new ThreadStart(Go)); t.Start( ); Go( ); } static void Go( ) { for (char c='a'; c<='z'; c++ ) Console.Write(c); } }
In this example, a new thread object is constructed by passing it a ThreadStart delegate that wraps the method that specifies where to start execution for that thread. You then start the thread and call Go, so two separate threads are running Go in parallel. However, there’s a problem: both threads share a common resource—the console. If you run ThreadTest, you could get output like this:
abcdabcdefghijklmnopqrsefghijklmnopqrstuvwxyztuvwxyz
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.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12609)
Hello! Python by Anthony Briggs(9931)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9806)
The Mikado Method by Ola Ellnestam Daniel Brolund(9797)
Dependency Injection in .NET by Mark Seemann(9354)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8317)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7775)
Grails in Action by Glen Smith Peter Ledbrook(7708)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7573)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7239)
Microservices with Go by Alexander Shuiskov(7001)
Practical Design Patterns for Java Developers by Miroslav Wengner(6914)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6866)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6430)
Angular Projects - Third Edition by Aristeidis Bampakos(6280)
The Art of Crafting User Stories by The Art of Crafting User Stories(5798)
NetSuite for Consultants - Second Edition by Peter Ries(5725)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5547)
Kotlin in Action by Dmitry Jemerov(5078)
