delphi-multi-threaded-sort-algorithms
Multi-threaded Sort Algorithms in Delphi
- Active · last change 3-8-2026
- ★ 1 on GitHub
README
Delphi Multi-threaded Sorting Algorithms Visualizer
Overview
This is a VCL-based desktop application written in Delphi that demonstrates parallel execution, thread-safe UI interactions, and custom canvas drawing. The application visually demonstrates 9 different sorting algorithms running concurrently in real-time on a randomized dataset.
This project serves as an excellent demonstration of concurrent programming, algorithm implementation, and custom UI rendering in Delphi.
Features & Architecture Showcased
- Symmetric Concurrency: Nine independent
TThreadsubclasses execute symmetrically and concurrently, each implementing a distinct sorting algorithm:- Selection Sort
- Shell Sort
- Insertion Sort
- Merge Sort
- Quick Sort
- Heap Sort
- Bubble Sort
- Comb Sort
- Cocktail Shaker Sort
- Decoupled Rendering Engine: Custom plotting using
TPaintBoxandOnPaintevents.- Worker threads (
TSorterThread) focus purely on algorithmic logic and safely update shared state records via pointers. - A detached
TTimermaster loop safely ticks at ~33 FPS to independently query thread states and redraw the visual grids without blocking the UI thread.
- Worker threads (
- Double Buffering: Implemented
DoubleBuffered := Truenatively on controls to completely eliminate visual tearing and flickering during high frame-rate canvas repaints. - Real-time Color Cues:
- White/Grey: Unsorted elements.
- Red/Blue: Active elements currently being compared or swapped by an algorithm inside the worker thread.
- Green: Segments of data that are verified as sorted or have completed their algorithmic passes.
- Modern Delphi Constructs:
- Built-in memory leak detection (
ReportMemoryLeaksOnShutdown := True;) demonstrating an awareness of robust memory management. - Usage of Generics (
TArray<Integer>) rather than static or legacy types. - Responsive, dynamically scaling UI grid (
OnResize) adjusting all 9 paint boxes seamlessly.
- Built-in memory leak detection (
How to use
- Open the
MultiSearchDemo.dprproject file in Embarcadero RAD Studio / Delphi. - Press F9 or hit Run.
- Maximize the window if desired, then click the Start Algorithms Visualization button.
- Watch a randomly shuffled array visually sort itself across all 9 algorithms simultaneously! "# delphi-multi-threaded-sort-algorithms"

