COMPSCI 230 S2C 2013 Software Design and Construction

lightnewsSoftware and s/w Development

Nov 18, 2013 (3 years and 11 months ago)

90 views

COMPSCI 230 S2C 2013
Software Design and Construction
Concurrency, Part 9
Revision
Learning Outcomes: Concurrency

Demonstrate a “theoretical understanding” of multi-
threaded computations

Hand-execute a simple multi-threaded program (“B” level)

Analyse a program to discover consistency and visibility defects
(“A” level)

Competently develop a multi-threaded program

Modify the threading behaviour of a simple program, e.g. produce
V2 of CalculatePrimesfrom an informal specification and a class
diagram (“B” level)

Accurately diagnose a deadlock condition (“A” level)

Demonstrate proficiency with the basic concepts and
vocabulary of concurrency in Java

Be able to define and use common terms and keywords, e.g.
volatile, mutex, synchronization (“C” level)
RevisionC9
Detailed Goals (from lecture slides)

[C1] Develop an appropriate “mental model” for multithreaded
programs.
Predict the outputs of a simple multithreaded program.

[C2] Understand why multithreading is important –and difficult!
List, and briefly discuss, some of the ways in which multithreading is used
in Java.

Recognise some common “design patterns” for multithreaded
computations: Model-View-Controller, simulation with one-thread-per-
actor, foreground/background computations.

Explain how a volatilevariable differs from a non-volatile one: what
are its advantages and disadvantages?
RevisionC9
Detailed Goals (from lecture slides)

[C2] Refine your understanding of threading:
Make a careful distinction between the support of an operating system
(or a computer) for running a thread, and an instance of a Thread object
in the execution of a Java program.

[C2] Understand the “lifecycle” of a thread
Start to analyse a multi-threaded application, by identifying “where” in the
code the state of a thread can change state i.e. are created, become
runnable, start to wait, stop waiting, and are terminated.
RevisionC9
Detailed Goals (from lecture slides)

[C3] Distinguish daemons from user threads 
How are they different? What are they doing in your JVM?

[C3] What are some of the common uses of multithreading in Java?
What is the “thread architecture” of AWT/Swing? Which tasks belong on
which thread? What can happen if the EDT is handling tasks that belong
on the model or controller thread?

What is a TimerTask, an RMI, a servlet, and a JSP? When might I want to
use these libraries in Java?

[C3] Develop a working understanding of synchronization
What are locks? Atomic operations? Synchronized methods? When
should I use them?

What can happen if an application has defective synchronization?
RevisionC9
Detailed Goals (from lecture slides)

[C4] Develop a stronger understanding of synchronization in Java.
Be able to analyse codes with a small number of interactions between a
few threads, answering the question “what execution traces are possible?”

[C4] Learn the syntax for synchronized methods
What are the disadvantages of this “syntactic sugar”?

[C4] Learn an important design pattern: using a final instance of a
collection to synchronize its methods.
A simple example: a thread-safe cache
RevisionC9
Detailed Goals (from lecture slides)

[C5] Have a solid understanding of synchronization 
Learn a new word and a new concept: mutex, and mutual exclusion

Work through a few more examples

Know Goetz’s advice on when to use, and when not to use,
synchronization.

[C5] Be able to diagnose a deadlocked system
Note: deadlock avoidance is beyond the scope of CompSci230.

[C5] Start to develop your own position on the relative
importance of designing for features, correctness, security, and
performance.
Agility and maintainability may be more important than some of the
above… remember XP?

Consider taking Goetz’s advice and my advice, then decide for yourself!
RevisionC9
Detailed Goals (from lecture slides)

[C6] Learn some more Java: 
wait(), notify(), notifyAll(), thread priorities,
thread groups, Thread.UncaughtExceptionHandler(),
SwingUtilities.invokeLater(),
SwingUtilities.invokeNow().

Know when and where to use these methods.

[C6] Know the rough outlines of Goetz’s advice on dealing with interruptedException().

[C6] Confirm your understanding of multi-threading in Java
Summarise what you learned from Goetz’s introduction (and from my
presentation of it)

Start to prepare for graduation: you don’t reallyneed me to learn other
advanced features of Java, do you?
RevisionC9
Detailed Goals (from lecture slides)

[C7] Know the rough outlines of Goetz’s advice on dealing with interruptedException().

[C7] Confirm your understanding of multi-threading in Java
Summarise what you learned from Goetz’s introduction (and from my presentation
of it)

Start to prepare for graduation: you don’t reallyneed me to learn other advanced
features of Java, do you?

[C7] A brief introduction to executors, tasks, concurrent collections, and
synchronizers.
You’ll know, roughly, what they do. This is just an introduction!

You won’t know how to use them well.

You will have some ideas on what (and how!) you’ll have to read & study, if you want
to learn how to use these well.

[C7] Start to develop your own point of view on the importance of learning
low-level “assembly language”.
You’ll usually be programming in high-level constructs, so you don’t really need to
know the low-level stuff. Or do you?
RevisionC9
Detailed Goals (from lecture slides)

[C8] Work through most of the “Concurrency in Swing” tutorial at http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html

Know how to use the three types of threads in a Swing app

Develop a vague understanding of how background tasks are controlled
in Swing (but you won’t know the names of methods, or their detailed
semantics)
RevisionC9