Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2002, Mike Murach & Associates, Inc.

Similar presentations


Presentation on theme: "© 2002, Mike Murach & Associates, Inc."— Presentation transcript:

1 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

2 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

3 © 2002, Mike Murach & Associates, Inc.
Concept of Threads What is a thread? - is a single sequential flow of control within a program and completes the specific task. Why thread? - multitasking can improve performance by multithreading technology - improve efficiency How thread works? - thread schedule determines which thread runs at a give time When use threads? - used to allow a time-consuming task to occur in the background JAVA, C20 © 2002, Mike Murach & Associates, Inc.

4 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

5 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

6 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

7 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

8 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

9 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

10 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

11 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

12 © 2002, Mike Murach & Associates, Inc.
More complete examples in textbook CD: BookExamples/Ch20/20-04/ JAVA, C20 © 2002, Mike Murach & Associates, Inc.

13 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

14 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

15 © 2002, Mike Murach & Associates, Inc.
More complete examples in textbook CD: BookExamples/Ch20/20-05/ JAVA, C20 © 2002, Mike Murach & Associates, Inc.

16 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

17 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

18 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

19 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

20 © 2002, Mike Murach & Associates, Inc.
More complete examples in textbook CD: BookExamples/Ch20/20-07/ JAVA, C20 © 2002, Mike Murach & Associates, Inc.

21 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

22 Concept of Synchronization in Threads
Asynchronous problems will occur when two or more threads are sharing data or/and sharing operation. For example: Producer-consumer relationship Threads must be synchronized in order to cooperate each other to operate correctly Java provides synchronized keyword to let a thread “exclusive-use” the shared resource until it’s finished to notify() other wait()ing thread to use This technology is also called “monitor” JAVA, C20 © 2002, Mike Murach & Associates, Inc.

23 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

24 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

25 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

26 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

27 © 2002, Mike Murach & Associates, Inc.
JAVA, C20 © 2002, Mike Murach & Associates, Inc.

28 © 2002, Mike Murach & Associates, Inc.
More complete examples in textbook CD: BookExamples/Ch20/20-10/ JAVA, C20 © 2002, Mike Murach & Associates, Inc.


Download ppt "© 2002, Mike Murach & Associates, Inc."

Similar presentations


Ads by Google