Code Explainers
Code explainers tagged #concurrency
rust
use std::collections::HashMap; use std::sync::{Arc, Mutex}; use std::thread;
Aggregating metrics across threads in Rust
concurrency
shared-state
mutex
Intermediate
7 steps
java
public class ThumbnailProcessor { private static final int MAX_CONCURRENCY = 4;
Bounded parallel thumbnail rendering in Java
concurrency
thread-pool
futures
Intermediate
7 steps
rust
use std::sync::{mpsc, Arc, Mutex}; use std::thread; use std::time::Duration;
Building a thread pool in Rust
concurrency
channels
thread-pool
Advanced
9 steps
go
package cache import ( "container/list"
Building a generic LRU cache in Go
lru-cache
generics
linked-list
Intermediate
8 steps
java
@Entity @Table(name = "accounts") public class Account {
Optimistic locking with @Version in Spring
optimistic-locking
jpa
concurrency
Advanced
7 steps
python
import time import threading
How a thread-safe token bucket rate limiter works
rate-limiting
concurrency
locking
Intermediate
6 steps
java
public class WorkPipeline { private final BlockingQueue<Task> queue = new LinkedBlockingQueue<>(1000); private static final Task POISON = new Task(-1, null); private final ExecutorService consumers = Executors.newFixedThreadPool(4);
A producer-consumer pipeline in Java
concurrency
producer-consumer
blocking-queue
Intermediate
8 steps
go
package debounce import ( "sync"
Building a debouncer in Go
concurrency
debounce
timers
Intermediate
6 steps
go
package retry import ( "context"
Retry with exponential backoff in Go
retry
exponential-backoff
jitter
Intermediate
8 steps
java
import java.time.Duration; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture;
A safe recurring heartbeat scheduler in Java
concurrency
scheduling
thread-safety
Intermediate
6 steps
go
package worker import ( "fmt"
A graceful worker pool in Go
concurrency
goroutines
channels
Intermediate
7 steps
ruby
class Throttle def initialize(interval) @interval = interval @mutex = Mutex.new
A thread-safe throttle in Ruby
concurrency
rate-limiting
mutex
Intermediate
7 steps
ruby
class ThreadSafeCounter def initialize(initial = 0) @count = initial @mutex = Mutex.new
A thread-safe counter with Mutex in Ruby
concurrency
mutex
thread-safety
Intermediate
6 steps
rust
use std::thread; pub fn parallel_map_reduce<T, M, R, F, G, H>( data: &[T],
A parallel map-reduce with scoped threads
concurrency
scoped-threads
map-reduce
Advanced
8 steps
go
package main import "sync"
Mutex vs RWMutex in Go
concurrency
mutex
synchronization
Intermediate
6 steps
rust
use std::sync::mpsc; use std::thread; use std::time::Duration;
A worker thread driven by Rust channels
concurrency
message-passing
channels
Intermediate
8 steps