SYSC-3303-02-ThreadProgramming

SYSC-3303-02-ThreadProgramming - 1 We will be using a RTOS...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: 1 We will be using a RTOS version of Linux, but anything that we are doing right now with threading, is just plain concurrency. 2 3 4 Important notes to write down: Looking at Thread and MyThread in the sequence diagram. The thread that is executing run() can send messages to objects, but doing so does not cause those objects to become threads When a thread sends a message to an object, the method is executed in the context of the invoking thread 5 Single threaded, sequential program. Draw sequence diagram on the board and demonstrate the single thread of control. 6 Threaded version of the same problem. Note the different uses of the Runnable interface and the Thread class (to avoid multiple inheritance) Tickers run() is now the implementation of Runnables method. Counter must override Threads run() method What will it do? Read from the console to a QUIT In discussion In discussion, Show Simulations use of new and start. Show how both Counters read from the console. Who gets it ? Non determined! Show how we cant tell the Counters apart. How could we? Look at Thread API and propose an approach. After discussion, show how it is still not really threaded. We have threads but not making use of it well! We need to synchronize these threads. Seque: Next Lecture. 7 8 Stopping a Thread: Java Developers Almanac 1.4 The proper way to stop a running thread is to set a varaible that the thread checks occasionally. When the thread detects that the variable is set, it should return from the run() method. Waitin for Thread to terminate: join( Waiting for Thread to terminate: join() Note the use of exceptions!...
View Full Document

Page1 / 20

SYSC-3303-02-ThreadProgramming - 1 We will be using a RTOS...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online