CrawlScript /
WebCollector
WebCollector is an open source web crawler framework based on Java.It provides some simple interfaces for crawling the Web,you can setup a multi-threaded web crawler in less than 5 minutes.
86/100 healthLoading repository data…
M-AdanAli / repository
A Java multi-threaded alarm system demonstrating concurrency primitives like Semaphore and ArrayBlockingQueue. It manages a bounded buffer for alarm slots, ensuring thread-safe scheduling and execution for multiple concurrent clients.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A basic Java project that serves as a robust example of Java concurrency primitives (Semaphore and ArrayBlockingQueue) applied to a simple alarm clock system. This project simulates multiple threads (clients) concurrently setting and waiting for alarms to ring.
The project simulates a centralized Alarm Service that manages a limited number of alarm slots. It uses Java's built-in concurrency mechanisms to enforce:
MAX_ALARMS).This is an in-memory, multi-threaded application—it does not use network sockets but demonstrates the fundamental logic required for managing concurrent requests in a backend system.
The structure follows standard Java package naming conventions:
.
└── com.adanali.java
├── model
│ └── Alarm.java (Data model for an alarm)
├── service
│ └── AlarmService.java (Centralized alarm management logic)
└── model
└── App.java (Main class for execution and testing)
Alarm.java (Model)A simple Plain Old Java Object (POJO) that holds the alarm data:
dateTime: A java.time.LocalDateTime object specifying when the alarm should trigger.title: A String to identify the alarm.AlarmService.java (Service/Manager)This is the core of the application, implemented as a Singleton using a Java enum.
alarms: An ArrayBlockingQueue<Alarm> of size 5. This thread-safe queue acts as the bounded buffer for pending alarms.spots (Semaphore): Initialized to MAX_ALARMS (5). Controls the producer (thread adding an alarm) access to the buffer.
acquire() a spot before adding an alarm, ensuring the buffer capacity is never exceeded.clientSpots (Semaphore): Initialized to MAX_ALARMS (5). Controls the consumer (thread waiting for an alarm) access.App.java (Main Execution)This class sets up the simulation:
AlarmService.INSTANCE::startAlarming.addAlarm)AlarmService.INSTANCE.addAlarm(alarm).spots Semaphore. If the buffer is full (5 alarms already waiting), the thread blocks until a permit is released.ArrayBlockingQueue.startAlarming)AlarmService.INSTANCE.startAlarming().clientSpots Semaphore.alarms.take(), which blocks if the queue is empty, waiting for a new alarm to be added.Duration.between(...)).Thread.sleep() to pause for the exact duration until the alarm time.spots and clientSpots, allowing a new producer thread to set an alarm and a new consumer thread to wait for it.The ingenious use of two separate Semaphores, though complex, helps control the flow:
| Component | Synchronization Primitive | Role |
|---|---|---|
| Alarm Buffer | ArrayBlockingQueue<Alarm> | Thread-safe Bounded Buffer (Size 5). Handles the actual storage and blocking when empty (take()) or full (implicitly handled by spots). |
| Producer Flow | Semaphore spots | Limits the number of Producers that can add an alarm to the queue to 5. |
| Consumer Flow | Semaphore clientSpots | Limits the number of Consumers that can be actively waiting or sleeping for an alarm to trigger to 5. |
This implementation ensures that at any given moment, only up to 5 alarms can be pending or actively ringing.
You will need the Java Development Kit (JDK) installed (version 8 or higher is compatible, but Java 17+ is recommended for modern development).
Ensure your files are structured with the correct packages:
.
└── com.adanali.java
├── model
│ └── Alarm.java (Data model for an alarm)
├── service
│ └── AlarmService.java (Centralized alarm management logic)
└── model
└── App.java (Main class for execution and testing)
Open your terminal in the src directory (or use an IDE like IntelliJ or Eclipse):
# 1. Compile the code (from the src directory)
javac com/adanali/java/model/Alarm.java com/adanali/java/service/AlarmService.java com/adanali/java/App.java
# 2. Run the main class
java com.adanali.java.App
Expected Output
The output will show the concurrent nature of the process, with alarms being added and then ringing after their scheduled delay:
Added Alarm 0 for : 2025-12-03T09:46:17.123
Added Alarm 1 for : 2025-12-03T09:46:17.223
....
Added Alarm 4 for : 2025-12-03T09:46:17.523
.... (Pause while the consumer threads wait for the time to pass)
Alarm Ringing : Alarm 0
Alarm Ringing : Alarm 1
📜 License : This project is licensed under the MIT License.
Selected from shared topics, language and repository description—not editorial ratings.
CrawlScript /
WebCollector is an open source web crawler framework based on Java.It provides some simple interfaces for crawling the Web,you can setup a multi-threaded web crawler in less than 5 minutes.
86/100 healthKajanM /
DirBuster is a multi threaded java application designed to brute force directories and files names on web/application servers.
67/100 healthkanyun-inc /
Ytk-mp4j is a fast, user-friendly, cross-platform, multi-process, multi-thread collective message passing java library which includes gather, scatter, allgather, reduce-scatter, broadcast, reduce, allreduce communications for distributed machine learning.
dasanjos /
A simple multi-threaded HTTP 1.1 Server implemented in Java for educational purposes based on W3C specifications
56/100 healthonblog /
A compact, flexible Java multi-threaded crawler framework (Ai Pa), built-in Jsoup, zero-cost hands-on.一款小巧、灵活的Java多线程爬虫框架(AiPa)内嵌Jsoup 零成本上手(欢迎Star,🚫禁止Fork)
60/100 healthabhi195 /
A multithreaded client/server Chat application based on the console which uses Java Socket programming and multi-threading.
62/100 health