Assignment 7-A

Multithreading Project

Build a multithreaded application demonstrating concurrency concepts. Master thread creation, synchronization, and concurrent utilities to solve complex parallel processing problems.

6-7 hours
Challenging
175 Points
Submit Assignment
What You'll Practice
  • Create and manage threads
  • Implement synchronization
  • Use ExecutorService and thread pools
  • Handle race conditions
  • Apply concurrent collections
Contents
01

Assignment Overview

Build a concurrent Task Scheduler and Processor that manages multiple tasks simultaneously. This project simulates a real-world scenario where multiple workers process tasks from a shared queue.

Thread Safety Required: All shared data must be properly synchronized. Race conditions and deadlocks will result in point deductions.
Skills Applied: Thread Fundamentals (7.1), Synchronization (7.2), and Concurrency Utilities (7.3) from Module 7.
Threads

Thread creation, lifecycle, Runnable, Callable

Synchronization

synchronized, locks, wait/notify

Executors

Thread pools, ExecutorService, Future

02

Requirements

Part 1: Task Queue (40 points)

  • Create a thread-safe TaskQueue using BlockingQueue
  • Implement producer threads that add tasks to the queue
  • Support task priorities (HIGH, MEDIUM, LOW)
  • Use PriorityBlockingQueue for priority-based processing

Part 2: Worker Pool (45 points)

  • Create a configurable worker pool using ExecutorService
  • Implement worker threads that process tasks from the queue
  • Use Callable and Future for tasks that return results
  • Implement graceful shutdown with timeout

Part 3: Synchronization Challenges (45 points)

  • Implement a SharedCounter using AtomicInteger
  • Create a producer-consumer scenario with wait/notify
  • Implement a read-write lock scenario for shared data
  • Demonstrate deadlock prevention strategies

Part 4: Progress Monitoring (45 points)

  • Track task completion status in real-time
  • Use ConcurrentHashMap for task status storage
  • Implement CompletableFuture for async result handling
  • Create a progress reporter thread
03

Submission Guidelines

Folder Structure: Submit all files in a folder named assignment7_yourname
Required Files:
  1. Task.java - Task model with priority
  2. TaskQueue.java - Thread-safe queue implementation
  3. WorkerPool.java - ExecutorService-based worker pool
  4. SharedCounter.java - Thread-safe counter
  5. ProducerConsumer.java - Producer-consumer demo
  6. ProgressMonitor.java
  7. TaskScheduler.java - Main orchestrator
  8. README.txt
Ready to submit? Ensure no race conditions or deadlocks!
Submit Now
04

Grading Rubric

Criteria Points Description
Task Queue 40 Thread-safe queue with priority support
Worker Pool 45 Proper ExecutorService usage
Synchronization 45 Correct synchronization, no race conditions
Progress Monitoring 45 Real-time tracking with concurrent data structures
Total 175