Yesterday I received an email from one of the students from my Java class expressing gratitude for some work done in the previous class which greatly contributed to helping him understand the concept of the Observable Class and the Observer Interface. I try as much as possible to get the students to understand the concepts before the class ends, even if it means not completing the entire planned lecture. When I receive emails or messages from students commenting on how they enjoyed the class and how they have grasped the concepts taught, it really makes me happy and makes all the work done before class worth it. In the Java class yesterday, we started looking at Threads. We looked at processes, then the main reasons for threads and the two main ways to create a Thread in Java…using the Thread class and using the Runnable Interface. Throughout the class I reiterated the fact that since Java only allows single inheritance, the Thread class cannot be used to create a Thread if you would like to inherit from another class and in such an instance the Runnable Interface should be used. I gave the class a few examples on creating threads but for some reason they were having some problems grasping the concept. So I started the topic again from the top and ended the class with them creating two basic classes for the two ways to create a thread as shown below.
For the next class, we will look at the life cycle of a thread, thread synchronisation and multithreaded programs.