Somedata 1234 create delegate for entry point on

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: de-Off: Must take care of synchronization Thread represents a system thread Threads are launched with entry point delegate Object-oriented threading model No arguments passed to entry point Thread launch-state is set on object hosting the delegate Automatic ThreadPool for each app domain Threading Creating Thread // Instantiate class that shall execute on thread Pulsar pulsar = new Pulsar(); pulsar.SomeData = 1234; // Create delegate for entry point on instance ThreadStart threadStart = new ThreadStart(pulsar.Run); // Create new thread object and start the thread Thread thread = new Thread(threadStart); thread.Start(); // Do other things ... // Wait for thread to complete thread.Join(); 32 Synchronization System.Threading.Monitor System.Threading.Monitor class // Enter critical section or wait Monitor.Enter(this); // Perform guarded action internalState = SomeAction( ); // Release lock Monitor.Exit(this); // C# intrinsic equivalent lock (this) { internalState = SomeAction( ); } Synchronization Timers Timer class for timed callbacks 33 Outline I...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online