Skip to content

A multi-threaded system where workers retrieve tasks from a shared queue, process them, and save results safely. Demonstrates concurrency management, thread/goroutine coordination, and exception/error handling in Java and Go.

License

Notifications You must be signed in to change notification settings

Akhil-uc/Ride_Sharing_System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ride_Sharing_System

This project simulates a data processing system where multiple workers process tasks in parallel. It has been implemented in both Java and Go to compare how each language handles concurrency and error management.

Overview

The system creates several worker threads (or goroutines) that take tasks from a shared queue, process them with a short delay, and write results to an output file. It also logs when each worker starts, completes a task, or encounters an error.


Features

  • Shared task queue for storing tasks

  • Multiple workers running in parallel

  • Thread-safe file writing

  • Logging of all activities and errors

  • Graceful shutdown after all tasks finish


Technologies Used

  • Java: Threads, ExecutorService, BlockingQueue, try-catch

  • Go: Goroutines, Channels, WaitGroup, defer for cleanup


How to Run

  • Java
  1. Open terminal in the project folder

  2. Compile and run:

     javac RideSharingSystem.java
     java RideSharingSystem
    
  3. Check the output file results_java.txt

  • Go
  1. Open terminal in the Go folder

  2. Run:

     go run ridesharing.go
    
  3. Check the output file results_go.txt


Sample Output

  • Console:

        Worker-1 started
        Worker-2 processing task 3
        Worker-3 completed task 5
        All workers finished
    
  • Output File:

        Task 1 processed by Worker-2 (payload=ride-1)
        Task 2 processed by Worker-1 (payload=ride-2)
    

What I Learned

  • How to use threads in Java and goroutines in Go
  • How to avoid race conditions with synchronized access
  • How exception and error handling differ between Java and Go

About

A multi-threaded system where workers retrieve tasks from a shared queue, process them, and save results safely. Demonstrates concurrency management, thread/goroutine coordination, and exception/error handling in Java and Go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published