Java threading examples for the Operating Systems and Concurrent Computing (OS & CC) module at ATU. Demonstrates thread creation using both the Thread class and the Runnable interface.
This repository contains two self-contained Java demos that illustrate fundamental multithreading concepts. The ThreadDemo creates threads by extending the Thread class, while the RunnableDemo creates threads by implementing the Runnable interface. Both examples show thread lifecycle states, priority settings, sleep behaviour, and concurrent countdown execution.
- Thread creation by extending the
Threadclass - Thread creation by implementing the
Runnableinterface - Thread state monitoring (NEW, RUNNABLE, TIMED_WAITING, TERMINATED)
- Priority assignment (MIN_PRIORITY through MAX_PRIORITY)
- Real-time console output of thread name, priority, state, and alive status
- Pre-configured VS Code dev container with Java 21 (Zulu)
- Java JDK 17+ installed locally, or
- A GitHub account with access to GitHub Codespaces
Clone the repository:
git clone https://github.com/danielcregg/os-and-cc-threads.git
cd os-and-cc-threadsOr open directly in GitHub Codespaces for a zero-install experience.
Run the Thread class demo:
javac ie/atu/threadspackage/ThreadDemo/*.java
java ie.atu.threadspackage.ThreadDemo.ThreadDemoDriverRun the Runnable interface demo:
javac ie/atu/threadspackage/RunnableDemo/*.java
java ie.atu.threadspackage.RunnableDemo.RunnableDemoDriverBoth demos will launch two concurrent threads that count down from 10 to 1, printing thread state changes along the way.
- Language: Java 17+
- Dev Environment: VS Code Dev Containers / GitHub Codespaces
- Container Image: Ubuntu 22.04 with Zulu JDK 21
This project is licensed under the MIT License.