You might make the odd bug. Then this might be handy * Debugging multithreaded applications with netbeans

Used material and stuff

For the part concurrency we will use the book: Java Concurrency in Practice, by Brian Goetz,
See: book site

Futher the following papers:

Hand in regime

You are supposed to work in groups of two to three(max) students. Learning works best when discussing with someone who is on par with you in the subject matter. Choose your own partner and share your work in the provided repository. You may also work alone.\

You must hand your report on paper. One hand per group suffices. Make sure the hand in meets all sensible criteria like: it has page numbers if it is multi page. It contains the name(s) of the authors on the first page near the top. LaTeX is the preferred format and is what real software engineers would do.

What should the report contain?

We know the theory, so do not repeat it (at least not in any length).

  • Try to focus on the (sub) problem at hand, describe the problem and illustrate your solution with diagrams and snippets of code.

  • LaTeX might be handy here, using \lstinputlisting[firstline=..,lastline=..]{…​}.

  • 3 to 4 effective pages (excluding title page) will typically suffice.

What will happen during the assessments?

We typically have three assessment sessions in which we discuss the material you handed in. We will be sitting in the practicum room and call you in the order given further down on this page. The assessment takes between 5 and 10 minutes per student.

Using your report we will try to find out whether your claims on knowledge and understanding in your report is somehow also present 'in your head'. It is this discussion that will give you a grade, not what is on the paper.

You may bring whatever you like to bring. It will be our shared cheat paper, meaning anything you bring can be used in your advantage or against you.☺

Typically we will not be able to 'process' all students in one session, meaning that we assess anything whose due day has passed, even if that is more then one task. If the result of an assessment is unsatisfactory, you may request a resit. This resit must have taken place before the end of June 2017.

Restaurant Version 1
Exercise Desciption Restaurant V1
If you are a bit rusty on threading with Java, rehearse by visiting one of the tutorials on the web. The tutorial at the official oracle/sun site is quite good. Especially take care of synchronisation, the monitor concept and object lock ownership. This will be subject in the assessments and theory exam.

The initial restaurant sources can be find by following the link.

Hand in before end of week 2.

Restaurant Version 2
Exercise Desciption Restaurant V2

You start with the code from your first restaurant task. Before you start with this task, make a subversion TAG as described in the task description.

Hand in before end of week 3.

Restaurant Version 3
Exercise Desciption Restaurant V3 Make a complete redesign (and implement) the restaurant using executors and futures. All employees are allowed to do all tasks in this version.

Hand in before end of week 5.

The crossing task for PRO3 is an exercise in using executors. The description is in crossingtask, the source code to start with in

The project is a maven project and should pull in its dependencies automatically, when you try to build it with maven or netbeans. You will be able to run it, but it will not work as required, because the parts you need to implement are still missing.

You should find a solution to make this crossing safe for all kind of crossing configurations by using the new concurrency classes, especially the executor framework. Hint: as a first step try to make the crossing safe in case there is only one lane at each corner, the so called mono lane crossing. As always: produce a document on paper to have something for the assessment. In this case: add your name to the code, print it on paper and hand that paper in. The javadoc api documentation of the crossing can be found here too.

Hand in before end of week 6.

Week planning

The course is executed in 7 lecture weeks in the 1st half of semester 4, starting in the week of Wednesday 8th 2017.

Note that the plan for the 4 main exercises does not exactly match the week plan. Pay attention to the due date for hand in, which is expressed relative to the weeks.

1. Thread safety.

What is thread safety?

Sheets and handouts

sheets and handout

2. Sharing Objects

How to share or not to share data.

Sheets and handouts

sheets and handout

3. Composing Objects and Building Blocks

  • Make thread safe classes with (un)safe parts.

  • Get familiar with you concurrent enhanced friends.

Sheets and handouts Composing Objects

sheets and handout .Sheets and handouts building blocks sheets and handout

4. Task Execution and Cancellation and Shutdown

What is usefull work under concurrency and how to get it done, and how to stop your application gracefully.

Sheets and handouts Task Execution

sheets and handout

Sheets and handouts Cancellation and Shutdown

sheets handout

5. Applying Thread Pools and Avoiding Liveliness Hazards

  • Do not fiddle with threads. Get an executor to do it.

  • What are the dangers your program can meet.

Sheets and Handouts Applying Thread Pools

sheets and handout

Sheets and Handouts Avoiding Liveliness Hazards

sheets and handout

6. Performance and Scalability and Divide And Conquer, The Java Way

  • Does it work like you hope on you super duper multi core machine?

  • How to make big tasks small and concurrency wise better.

Sheets and handouts Performance and Scalability

sheets and handout

Sheets and handouts The Fork-Join Frame Work

sheets and handout

7. Lambda and the Streams API and Roundup

  • The Java8 enhancements, in particular the Streams API are optimized for concurrency. Let’s meet them.

  • Round up. Any last questions and discussions we may have.

Sheets and handouts Lambda and the Streams API

sheets and handout

For this week, view the video by Angelika Langer on the new concurrency utilities in Java 8, in particular the section about CompletableFuture from 3:20 till about 30:00.

This is also an interesting read. Blog on Java8 CompletableFuture,target=_blank