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:

Other resources

You need some NetBeans libraries.

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 should document your code appropriately, according to the Java doc style recommendations. You are advised to take notes while experimenting and present these notes during the oral assessment. You can make these notes in you source code, butt it is best to have these notes with you on paper.

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 notes and source code we will try to find out whether your claims on knowledge and understanding 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. 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 2018.

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. Note that you will have to declare some NetBeans libraries to get it working. A How to do that can be found, see the youtube film on that page. The link to the jar files to put in the library can be found above.

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.

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.

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.

Week planning

The course is executed in 14 lecture weeks in of semester 4.

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.

Hand in deadlines

For 2018 the deadlines are as follows:

Task Hand in

Crossing task

End of week 9

Restaurant V1

End of week 3

Restaurant V2

End of week 5

Restaurant V3

End of week 7

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

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

Sheets and handouts Composing Objects

sheets and handout

4. Building Blocks

  • Get familiar with you concurrent enhanced friends.

Sheets and handouts building blocks

sheets and handout

5. Task Execution

What is useful work under concurrency and how to get it done.

Sheets and handouts Task Execution

sheets and handout

6. Cancellation and Shutdown

How to stop your application gracefully.

Sheets and handouts Cancellation and Shutdown

sheets handout

7. Applying Thread Pools

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

Sheets and Handouts Applying Thread Pools

sheets and handout

8. (Avoiding) Liveliness Hazards

  • What are the dangers your program can meet.

Sheets and Handouts Avoiding Liveliness Hazards

sheets and handout

9. Performance and Scalability

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

Sheets and handouts Performance and Scalability

sheets and handout

10. Divide And Conquer, The Java Way

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

Sheets and handouts The Fork-Join Frame Work

sheets and handout

11. Lambda and the Streams API

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

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

12. RXJava, an alternate way to do concurrency.

Sheets on rxjava by Tim Wedde and Moritz Richter, as of Februari 2018 in their bachelor semester.

Study the sheets before you start with the wokdshop code.

13. Akka as alternative

Akka is a actor based framework. This morning we will execute the akka framework wokshop by Tobias Derksen and Max Messerich. The application will be familiar by now: Yet another restaurant.

The workshop can be found on github at SEBI Venlo Akka Workshop 2017

14. Roundup

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