# Concurrent Programming

Published articles for Concurrent Programming.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Fun with Algebraic Effects - from Toy Examples to Hardcaml Simulations

DevFeed: [Fun with Algebraic Effects - from Toy Examples to Hardcaml Simulations](<https://devfeed.tech/articles/fun-with-algebraic-effects-from-toy-examples-to-hardcaml-simulations-20168.md>)

Original publisher: [Read original article](<https://blog.janestreet.com/fun-with-algebraic-effects-hardcaml/>)

Author: Fu Yong Quah

Published: 2026-01-06T00:00:00Z

Content type: article

Language: en

Sources: [Jane Street](<https://devfeed.tech/sources/jane-street.md>)

Topics: [OCaml](<https://devfeed.tech/topics/ocaml.md>), [Library](<https://devfeed.tech/topics/library.md>), [Simulation](<https://devfeed.tech/topics/simulation.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>)

Tags: [blog](<https://devfeed.tech/tags/blog.md>), [blog-post](<https://devfeed.tech/tags/blog-post.md>), [code](<https://devfeed.tech/tags/code.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [library](<https://devfeed.tech/tags/library.md>), [ocaml](<https://devfeed.tech/tags/ocaml.md>)

### AI overview

The article describes porting Jane Street's Hardcaml_step_testbench library from monads to algebraic effects in OCaml 5. It explains algebraic effects, compares them with monads, and demonstrates how to use them with the Handled_effect library for Hardcaml simulations.

### Source excerpt

I recently ported the Hardcaml_step_testbench library, one of the libraries that we use at Jane Street for Hardcaml simulations, from using monads to using algebraic effects, a new OCaml 5 feature. This blog post walks through what algebraic effects are, why you should consider using them in lieu of monads, and how to actually work with them using the Handled_effect library. One thing I've come to believe is that most of what can be done with monads can be done with algebraic effects in a much more elegant way.

## How to deadlock Tokio application in Rust with just a single mutex

DevFeed: [How to deadlock Tokio application in Rust with just a single mutex](<https://devfeed.tech/articles/how-to-deadlock-tokio-application-in-rust-with-just-a-single-mutex-5965.md>)

Original publisher: [Read original article](<https://turso.tech/blog/how-to-deadlock-tokio-application-in-rust-with-just-a-single-mutex>)

Author: Piotr Jastrzebski

Published: 2024-09-02T00:00:00Z

Content type: tutorial

Language: en

Sources: [Turso Blog](<https://devfeed.tech/sources/turso-blog.md>)

Topics: [Tokio](<https://devfeed.tech/topics/tokio.md>), [Deadlock](<https://devfeed.tech/topics/deadlock.md>)

Tags: [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [deadlock](<https://devfeed.tech/tags/deadlock.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [rust](<https://devfeed.tech/tags/rust.md>), [tokio](<https://devfeed.tech/tags/tokio.md>), [turso](<https://devfeed.tech/tags/turso.md>)

### AI overview

A Tokio-based Rust program deadlocks when a synchronous task holds a std::sync::Mutex while blocking on a future. The article recommends tokio::sync::Mutex for this asynchronous scenario and cautions against premature optimization.

### Source excerpt

Battlefield story of how we managed to deadlock Tokio program with just a single mutex

## Ep. 1: Defending Against Memory Breaches: Exploring Rust and Go's Safety Mechanisms

DevFeed: [Ep. 1: Defending Against Memory Breaches: Exploring Rust and Go's Safety Mechanisms](<https://devfeed.tech/articles/ep-1-defending-against-memory-breaches-exploring-rust-and-go-s-safety-mechanisms-22277.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2024/15/defending-against-memory-breaches-exploring-rust-and-go-safety-mechanisms-ep-1.html>)

Published: 2024-04-15T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Rust](<https://devfeed.tech/topics/rust.md>), [Memory Safety](<https://devfeed.tech/topics/memory-safety.md>), [Go Language](<https://devfeed.tech/topics/go-language.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Security](<https://devfeed.tech/topics/security.md>)

Tags: [c](<https://devfeed.tech/tags/c.md>), [concurrent](<https://devfeed.tech/tags/concurrent.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [go](<https://devfeed.tech/tags/go.md>), [golang](<https://devfeed.tech/tags/golang.md>), [languages](<https://devfeed.tech/tags/languages.md>), [memory-breaches](<https://devfeed.tech/tags/memory-breaches.md>), [memory-management](<https://devfeed.tech/tags/memory-management.md>), [memory-safety](<https://devfeed.tech/tags/memory-safety.md>), [rust](<https://devfeed.tech/tags/rust.md>), [safety](<https://devfeed.tech/tags/safety.md>), [safety-mechanism](<https://devfeed.tech/tags/safety-mechanism.md>), [security](<https://devfeed.tech/tags/security.md>), [synchronization](<https://devfeed.tech/tags/synchronization.md>)

### AI overview

This introductory video examines memory safety in programming languages, focusing on Rust and comparing its approach with Go, Java, and C. It discusses buffer overflows, memory leaks, data races, static analysis, checked arithmetic, and the trade-offs between safety and performance.

### Source excerpt

Introduction: Rust's memory safety features are advantageous to Rust developers because they: Ensure robust protection against buffer overflows and underflows, enhancing the reliability and security of software. Empower developers to manage type coercion effectively, promoting code reliability and safety while facilitating safe type conversions. Provide confidence in writing concurrent code by enforcing strict mutability rules and synchronization, thereby preventing data race issues and ensuring code correctness and efficiency. With these memory safety features deeply integrated into Rust's design, developers can build more reliable, secure, and efficient software, spanning various aspects of memory management, type handling, and concurrent programming paradigms.

## Swift Concurrency Waits for No One

DevFeed: [Swift Concurrency Waits for No One](<https://devfeed.tech/articles/swift-concurrency-waits-for-no-one-27360.md>)

Original publisher: [Read original article](<https://saagarjha.com/blog/2023/12/22/swift-concurrency-waits-for-no-one/>)

Published: 2023-12-22T00:00:00Z

Content type: article

Language: en

Sources: [Saagar Jha](<https://devfeed.tech/sources/saagar-jha.md>)

Topics: [Swift](<https://devfeed.tech/topics/swift.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [Code](<https://devfeed.tech/topics/code.md>), [API](<https://devfeed.tech/topics/api.md>), [POSIX](<https://devfeed.tech/topics/posix.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [code](<https://devfeed.tech/tags/code.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [posix](<https://devfeed.tech/tags/posix.md>), [swift](<https://devfeed.tech/tags/swift.md>), [threads](<https://devfeed.tech/tags/threads.md>)

### AI overview

The article explains why Swift Concurrency requires careful handling when asynchronous work must be invoked from synchronous code and then awaited. It uses the example of spawning a Task and blocking with a semaphore to illustrate the complexity of preserving task forward progress, while contrasting Swift Concurrency with older concurrency APIs.

### Source excerpt

There was once a master engineer who lived by herself in a mystical, far off place, where nourishment flowed freely and the dirt beneath your feet was more valuable than gold. Inaccessible even by foot, only very few could make the trip for a chance at receiving her wisdom. A novice programmer, enthusiastic but still wet behind the ears, visited her one day. "I have read your code," he began, "and I can only describe it as sublime. But, I've been learning a lot about Swift Concurrency and I see that you don't use it all the time. Why is that?" The master engineer replied promptly with a question of her own: "Tell me, how would an asynchronous program call synchronous code?" "That's easy," he replied. "You can just call it directly." "Now, how would one invoke asynchronous code from a synchronous context?" "Spawn a Task, obviously!" replied the novice engineer, glad that his studies had come in handy. The master engineer smiled. "Very good. But now, imagine waiting for the work to complete before proceeding. What then? The API, naturally, is provided by the system and cannot be redesigned." This troubled the novice, and he furrowed his brow in concentration for some time. Finally, a half-forgotten memory came back to him: "DispatchSemaphore! I can use a semaphore to wait for the asynchronous work!" "Swift Concurrency requires tasks to make forward progress", responded the master engineer. Then she fell silent. After a while, the novice was enlightened.

## Concurrent Programming in Kotlin: Ensuring Thread Safety with Mutex

DevFeed: [Concurrent Programming in Kotlin: Ensuring Thread Safety with Mutex](<https://devfeed.tech/articles/concurrent-programming-in-kotlin-ensuring-thread-safety-with-mutex-23873.md>)

Original publisher: [Read original article](<https://engineering.premise.com/concurrent-programming-in-kotlin-ensuring-thread-safety-with-mutex-5d9c6b80644b?source=rss----c5fada0a103d---4>)

Author: Kwabena Bio Berko

Published: 2023-07-18T03:33:24Z

Content type: tutorial

Language: en

Sources: [Engineering at Premise - Medium](<https://devfeed.tech/sources/engineering-at-premise-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Database](<https://devfeed.tech/topics/database.md>), [Software Engineering](<https://devfeed.tech/topics/software-engineering.md>)

Tags: [atomic](<https://devfeed.tech/tags/atomic.md>), [code](<https://devfeed.tech/tags/code.md>), [component](<https://devfeed.tech/tags/component.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [concurrent](<https://devfeed.tech/tags/concurrent.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [data](<https://devfeed.tech/tags/data.md>), [database](<https://devfeed.tech/tags/database.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [function](<https://devfeed.tech/tags/function.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [io](<https://devfeed.tech/tags/io.md>), [issue](<https://devfeed.tech/tags/issue.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [let](<https://devfeed.tech/tags/let.md>), [mobile-app-development](<https://devfeed.tech/tags/mobile-app-development.md>), [mutex](<https://devfeed.tech/tags/mutex.md>), [safety](<https://devfeed.tech/tags/safety.md>), [suspend](<https://devfeed.tech/tags/suspend.md>), [thread](<https://devfeed.tech/tags/thread.md>)

### AI overview

This Kotlin tutorial explains how Mutex provides mutual exclusion when multiple threads or coroutines call a refresh function. It shows how locking can prevent duplicate network and database operations, avoid race conditions, and preserve atomicity, while withLock can suspend callers until the current lock is released.

### Source excerpt

By Kwabena Bio Berko, Android Engineer Photo by Chris Ried on Unsplash I have recently been experimenting with mutual exclusion(Mutex), a concept in software engineering to solve race conditions when accessing shared resources. Let's assume we have a component with a refresh function that can be accessed from multiple threads or coroutines: https://medium.com/media/e19aa2a9d57bc105b841d28061a199b8/href In the implementation of this component, the function retrieves data from a remote resource and inserts it into the local database. However, these operations need to be atomic. Now, imagine if 10 threads call this function simultaneously, or even a few milliseconds apart. What happens? If you guessed that we make 10 network calls and 10 database IO operations to save the items, then you would be right, as confirmed by the below test: https://medium.com/media/9b279658dbf87021068ee21a913dc80e/hrefhttps://medium.com/media/81cdc164ad807fd45df77389c00bd4cc/href But that's not what we want. It's definitely not resource-friendly. To address this issue, we can use a Mutex. As the name suggests, a Mutex provides mutual exclusion for a specific portion of your code, imposing restrictions on the access to that portion in situations where multiple threads or coroutines may attempt to access it concurrently. In essence, Mutex allows only one thread or coroutine to work within the confines of that portion of the code at any given time. By introducing a Mutex in our refresh function, we can ensure that only one thread is executing the critical sections of the code, preventing race conditions and ensuring atomicity of the operations. https://medium.com/media/9d88a802b4c73f14ceb4d5527158af5d/href In the example above, whenever the refresh function is called, we check to see if the Mutex is already locked or been used. If not, we lock it and then perform our network call and save the results in our local database. This means that whenever another thread or coroutine calls this refresh

## Leveraging the Semaphore concept in Coroutines to limit the parallelism 🔀

DevFeed: [Leveraging the Semaphore concept in Coroutines to limit the parallelism 🔀](<https://devfeed.tech/articles/leveraging-the-semaphore-concept-in-coroutines-to-limit-the-parallelism-25734.md>)

Original publisher: [Read original article](<https://blog.shreyaspatil.dev/leveraging-the-semaphore-concept-in-coroutines-to-limit-the-parallelism/>)

Author: Shreyas Patil

Published: 2022-04-01T12:57:35Z

Content type: tutorial

Language: en

Sources: [Shreyas Patil's Blog](<https://devfeed.tech/sources/shreyas-patil-s-blog.md>)

Topics: [kotlin-coroutines](<https://devfeed.tech/topics/kotlin-coroutines.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [multithreading](<https://devfeed.tech/tags/multithreading.md>), [mutex](<https://devfeed.tech/tags/mutex.md>), [synchronization](<https://devfeed.tech/tags/synchronization.md>), [threads](<https://devfeed.tech/tags/threads.md>)

### AI overview

A tutorial explaining semaphores in Kotlin coroutines, including binary and counting semaphores, and how permits limit parallel access to shared resources.

### Source excerpt

Explore the concept of Semaphores in Kotlin Coroutines. Learn how to limit parallelism and manage resource access in concurrent programming.

## Concurrent programming, with examples

DevFeed: [Concurrent programming, with examples](<https://devfeed.tech/articles/concurrent-programming-with-examples-21487.md>)

Original publisher: [Read original article](<https://begriffs.com/posts/2020-03-23-concurrent-programming.html>)

Published: 2020-03-23T00:00:00Z

Content type: article

Language: en

Sources: [Joe Nelson](<https://devfeed.tech/sources/joe-nelson.md>)

Topics: [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [API](<https://devfeed.tech/topics/api.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [concurrent](<https://devfeed.tech/tags/concurrent.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [posix](<https://devfeed.tech/tags/posix.md>), [thread](<https://devfeed.tech/tags/thread.md>)

### AI overview

An introductory article on concurrent programming that explains concurrency versus parallelism and covers threading and locking as practical techniques for building concurrent software. It introduces POSIX threads and discusses how concurrency can benefit from hardware parallelism, including limitations imposed by global interpreter locks in Ruby MRI and CPython.

### Source excerpt

2020-03-23 Mention concurrency and you're bound to get two kinds of unsolicited advice: first that it's a nightmarish problem which will melt your brain, and second that there's a magical programming language or niche paradigm which will make all your problems disappear. We won't run to either extreme here. Instead we'll cover the production workhorses for concurrent software - threading and locking - and learn about them through a series of interesting programs.

## Ruby Processes and Threads - Configuring a Web Server

DevFeed: [Ruby Processes and Threads - Configuring a Web Server](<https://devfeed.tech/articles/ruby-processes-and-threads-configuring-a-web-server-21076.md>)

Original publisher: [Read original article](<https://jakeyesbeck.com/2019/06/18/ruby-processes-and-threads/>)

Published: 2019-06-18T12:00:00Z

Content type: article

Language: en

Sources: [Jake Yesbeck](<https://devfeed.tech/sources/jake-yesbeck.md>)

Topics: [Ruby](<https://devfeed.tech/topics/ruby.md>), [Processes](<https://devfeed.tech/topics/processes.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [Server](<https://devfeed.tech/topics/server.md>), [Rails](<https://devfeed.tech/topics/rails.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [database](<https://devfeed.tech/tags/database.md>), [processes](<https://devfeed.tech/tags/processes.md>), [rails](<https://devfeed.tech/tags/rails.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [server](<https://devfeed.tech/tags/server.md>)

### AI overview

This article explains how Ruby web servers use threads and processes to handle concurrent requests. It covers I/O blocking, Ruby's Global Interpreter Lock, process-based parallelism, and the CPU, memory, and database-connection tradeoffs involved in server configuration.

### Source excerpt

Multiple popular Ruby web servers exist. Each Ruby application is different and the ultimate tl;dr for configuring a web server is: it depends. This post will not prescribe one web server or configuration over another and will instead explain internal components most popular servers contain. In order to facilitate more than one request at a time, a Ruby web server implements Threads, Processes, or both. These tools are used to enable concurrency and are beneficial in different ways. Threads Threads in Ruby are a solution for concurrent programming and can alleviate slow downs due to blocking code. This blocking is usually referred to as "I/O" or Input/Output blocking and occurs when a program must reach out for additional information. External API calls, reading from disk, and querying a database are all examples of blocking operations. When using multiple Threads, an application can continue to function while one Thread is waiting. Most Ruby code in the wild is running on MRI (if you're not sure what you're using, there is a good chance this is what you use). Because of this, Ruby Threads are subject to the Global Interpreter Lock or GIL. The GIL prevents any two threads in the same process from running at exactly the same time making true parallelism not possible. Processes One way to allow for true parallelism in Ruby is to use multiple Processes. A Ruby Process is the instance of an application or a forked copy. In a traditional Rails application, each Process contains all the build up, initialization, and resource allocation the app will need. Running multiple Proccesses can enable more efficient usage of some server resources like the CPU but is not without its downsides. Because each process must boot and provision an entire app, memory usage or database connection saturation can become a limiting factor. Tempering the Metal When configuring on a web server, an application's request shape is the most important factor to consider. Web application requests can

## Goroutine Leaks - The Forgotten Sender

DevFeed: [Goroutine Leaks - The Forgotten Sender](<https://devfeed.tech/articles/goroutine-leaks-the-forgotten-sender-22139.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2018/11/goroutine-leaks-the-forgotten-sender.html>)

Published: 2018-11-12T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [Memory Leaks](<https://devfeed.tech/topics/memory-leaks.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [ardan-labs](<https://devfeed.tech/tags/ardan-labs.md>), [blog](<https://devfeed.tech/tags/blog.md>), [code-review](<https://devfeed.tech/tags/code-review.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [go](<https://devfeed.tech/tags/go.md>), [go-programming](<https://devfeed.tech/tags/go-programming.md>), [golang](<https://devfeed.tech/tags/golang.md>), [goroutines](<https://devfeed.tech/tags/goroutines.md>), [memory-leak](<https://devfeed.tech/tags/memory-leak.md>), [memory-management](<https://devfeed.tech/tags/memory-management.md>), [performance](<https://devfeed.tech/tags/performance.md>), [programming](<https://devfeed.tech/tags/programming.md>), [review](<https://devfeed.tech/tags/review.md>)

### AI overview

This article explains how goroutine leaks occur in Go concurrent programs. It describes a leak as a goroutine that is expected to terminate but remains blocked indefinitely, keeping its allocated memory for the lifetime of the application, and illustrates how a goroutine waiting on a channel can become unreachable when its calling function returns.

### Source excerpt

Introduction Concurrent programming allows developers to solve problems using more than one path of execution and is often used in an attempt to improve performance. Concurrency doesn't mean these multiple paths are executing in parallel; it means these paths are executing out-of-order instead of sequentially. Historically, this type of programming is facilitated using libraries that are either provided by a standard library or from 3rd party developers. In Go, concurrency features like Goroutines and channels are built into the language and runtime to reduce or eliminate the need for libraries. This has created the illusion that writing concurrent programs in Go is easy. You must be cautious when deciding to use concurrency as it comes with some unique side effects or traps if not used correctly. These traps can create complexity and nasty bugs if you're not careful.

## Ruby Threads and ActiveRecord Connections

DevFeed: [Ruby Threads and ActiveRecord Connections](<https://devfeed.tech/articles/ruby-threads-and-activerecord-connections-21063.md>)

Original publisher: [Read original article](<https://jakeyesbeck.com/2016/02/14/ruby-threads-and-active-record-connections/>)

Published: 2016-02-14T12:00:00Z

Content type: tutorial

Language: en

Sources: [Jake Yesbeck](<https://devfeed.tech/sources/jake-yesbeck.md>)

Topics: [Ruby](<https://devfeed.tech/topics/ruby.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Database](<https://devfeed.tech/topics/database.md>), [API](<https://devfeed.tech/topics/api.md>)

Tags: [activerecord](<https://devfeed.tech/tags/activerecord.md>), [api](<https://devfeed.tech/tags/api.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [database](<https://devfeed.tech/tags/database.md>), [ruby](<https://devfeed.tech/tags/ruby.md>)

### AI overview

This article explains how Ruby threads can process large datasets concurrently while sharing memory within a process. Using ActiveRecord, it demonstrates batched email validation through an external API and discusses the accumulation of database connections created by spawned threads.

### Source excerpt

Processing large data sets is a common problem faced by many production web applications. One solution is to divide the work amongst multiple processes and have each responsible for a single or significantly smaller batch of data. However, this solution is not without its problems. Machine provisioning limitations or financial barriers may invalidate this solution for a very large N. Within the same vein as "divide and conquer" exists another solution, one which requires far fewer parallel processes: Threads. In the Ruby programming language, a Thread is a built-in object for concurrent programming. Unlike independent processes, all Ruby Threads within the same process share memory, enabling each individual Thread to consume or process objects and elements from the same data store. For this example, a database will be queried, results manipulated and finally returned to same database via ActiveRecord. First Pass Given a User model backed by a simple users table: class User < ActiveRecord::Base end class CreateUsersTable < ActiveRecord::Migration def change create_table :users do |t| t.string :first_name t.string :last_name t.string :email t.boolean :validated, default: false t.timestamps null: false end end end The problem to solve is fairly straight forward: All User records that are not already validated should be fetched and an external API hit with their email address for validation, then saved. If a User's email address is not valid, it should be removed. Fast forwarding through time, it can be assumed that a completely serial solution has been written and deemed unsatisfactory. Then, during a second iteration, a bit of concurrent code was written: class UserEmailValidator def self.run User.where(validated: false) .find_in_batches(batch_size: 30) do |user_batch| validate_emails(user_batch) end end def self.validate_emails(user_batch) threads = user_batch.map do |user| Thread.new do email_validator = EmailService.new(user.email) email_validator.validate user.ema

## Building the new SoundCloud iOS application -- Part I: The reactive paradigm

DevFeed: [Building the new SoundCloud iOS application -- Part I: The reactive paradigm](<https://devfeed.tech/articles/building-the-new-soundcloud-ios-application-part-i-the-reactive-paradigm-2005.md>)

Original publisher: [Read original article](<https://developers.soundcloud.com/blog//building-the-new-ios-app-a-new-paradigm>)

Published: 2014-07-07T00:00:00Z

Content type: article

Language: en

Sources: [SoundCloud Backstage Blog](<https://devfeed.tech/sources/soundcloud-backstage-blog.md>)

Topics: [iOS](<https://devfeed.tech/topics/ios.md>), [reactive](<https://devfeed.tech/topics/reactive.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [API](<https://devfeed.tech/topics/api.md>), [Database](<https://devfeed.tech/topics/database.md>), [event driven](<https://devfeed.tech/topics/event-driven.md>), [JSON](<https://devfeed.tech/topics/json.md>), [client](<https://devfeed.tech/topics/client.md>), [Network](<https://devfeed.tech/topics/network.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [database](<https://devfeed.tech/tags/database.md>), [http](<https://devfeed.tech/tags/http.md>), [ios](<https://devfeed.tech/tags/ios.md>), [json](<https://devfeed.tech/tags/json.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [network](<https://devfeed.tech/tags/network.md>), [programming](<https://devfeed.tech/tags/programming.md>), [reactive](<https://devfeed.tech/tags/reactive.md>)

### AI overview

This article describes SoundCloud's rewrite of its iOS application and its adoption of the functional reactive paradigm with Reactive Cocoa. It explains how composable event-driven data streams can unify data transformations, error handling, storage mapping, and concurrency management in a mobile API client.

### Source excerpt

Recently, SoundCloud launched the new iOS application which was a complete rewrite of the existing iOS application. The Mobile engineering...

## The Essential Leslie Lamport

DevFeed: [The Essential Leslie Lamport](<https://devfeed.tech/articles/the-essential-leslie-lamport-12454.md>)

Original publisher: [Read original article](<http://brooker.co.za/blog/2014/03/30/lamport-pub.html>)

Author: Marc Brooker

Published: 2014-03-30T00:00:00Z

Content type: opinion

Language: en

Sources: [Marc Brooker's Blog](<https://devfeed.tech/sources/marc-brooker-s-blog.md>), [Marc Brooker's Blog](<https://devfeed.tech/sources/marc-brooker-s-blog-2.md>)

Topics: [Algorithm](<https://devfeed.tech/topics/algorithm.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Computer science](<https://devfeed.tech/topics/computer-science.md>)

Tags: [concurrent](<https://devfeed.tech/tags/concurrent.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [programming](<https://devfeed.tech/tags/programming.md>), [publications](<https://devfeed.tech/tags/publications.md>), [science](<https://devfeed.tech/tags/science.md>)

### AI overview

The article recommends selected Leslie Lamport publications, focusing on the bakery algorithm for mutual exclusion in concurrent programming and on the ordering of events in distributed systems using logical clocks. It presents these works as particularly elegant and valuable for understanding computer science.

### Source excerpt

The Essential Leslie Lamport Some of my favourite Leslie Lamport publications. After it was announced that Leslie Lamport had won the 2013 A.M. Turing award, the link to his list of publications found popularity on most of the tech-related sites I visit. It's an excellent page, with a long (and growing) list of Lamport's publications, and witty comments by the author on each one. The whole list is worth a read, but can feel overwhelming, so I thought I'd try distill it down it some papers that I feel are really worth reading, if you read nothing else on that page. The criteria are: I like these papers for some reason. I'd probably make a different list if I wrote this post again next week. The algorithm is quite simple. It is based upon one commonly used in bakeries, in which a customer receives a number upon entering the store. The holder of the lowest number is the next one served. In A New Solution of Dijkstra's Concurrent Programming Problem Lamport describes the mutual exclusion problem formally posed by Dijkstra, and presents a solution to it. The bakery algorithm is remarkable. Unlike the earlier solutions, which depended on shared memory locations with fairly restrictive behaviors, the bakery algorithm works without any underlying mutual exclusion. Lamport's invention, or discovery, of this algorithm seems to kicked off a cascade of other solutions. Szymanski's, which seems to have been the first to offer both strong fairness and use of a fixed number of shared variables of a bounded size, is particularly interesting. Why this is worth reading: The bakery algorithm, while not very relevant to today's concurrent software due to changes in memory models, is very simple, very beautiful, and solves a complex problem in an innovative way. It's simply a beautiful piece of computer science. In a distributed system, it is sometimes impossible to say that one of two events occurred first. The relation "happened before" is therefore only a partial ordering of the even

## Disruptor 2.0 Released

DevFeed: [Disruptor 2.0 Released](<https://devfeed.tech/articles/disruptor-2-0-released-13612.md>)

Original publisher: [Read original article](<https://mechanical-sympathy.blogspot.com/2011/08/disruptor-20-released.html>)

Author: Martin Thompson (noreply@blogger.com)

Published: 2011-08-27T08:49:00Z

Content type: release

Language: en

Sources: [Mechanical Sympathy](<https://devfeed.tech/sources/mechanical-sympathy.md>)

Topics: [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [Java](<https://devfeed.tech/topics/java.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [concurrent](<https://devfeed.tech/tags/concurrent.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [dependency](<https://devfeed.tech/tags/dependency.md>), [disruptor](<https://devfeed.tech/tags/disruptor.md>), [framework](<https://devfeed.tech/tags/framework.md>), [graph](<https://devfeed.tech/tags/graph.md>), [java](<https://devfeed.tech/tags/java.md>), [performance](<https://devfeed.tech/tags/performance.md>), [queue](<https://devfeed.tech/tags/queue.md>), [release](<https://devfeed.tech/tags/release.md>)

### AI overview

This release article announces Disruptor 2.0, highlighting a cleaner API, renamed event-processing concepts, a DSL for assembling EventProcessor dependency graphs, and substantial performance improvements over queue-based approaches.

### Source excerpt

Significantly improved performance and a cleaner API are the key takeaways for the Disruptor 2.0 concurrent programming framework for Java. This release is the result of all the great feedback we have received from the community. Feedback is very welcome and really improves the end product so please keep it coming. You can find the Disruptor project here, plus we have a wiki with links to detailed blogs describing how things work. Naming & API Over the lifetime of the Disruptor naming has been a challenge. The funny thing is that with the 2.0 release we have come almost full circle. Originally we considered the Disruptor as an event processing framework that often got used as a queue replacement. To make it understandable to queue users we adopted the nomenclature of producers and consumers. However the consumers are not true consumers. With this release the consensus is to return to the event processing roots and adopt the following naming changes. Producer -> Publisher Events are claimed in strict sequence and published to the RingBuffer. Entry -> Event Events represent the currency of data exchange through the dependency graph of EventProcessors. Consumer -> EventProcessor Events are processed by EventProcessors. The processing of an event can be read only, but can also involve mutations on which other EventProcessors depend. ConsumerBarrier -> DependencyBarrier Complex graphs of dependent EventProcessors can be constructed for the processing of an Event. The DependencyBarriers are assembled to represent the dependency graph. This topic is the real value of the Disruptor and often misunderstood. A fun example can be seen playing FizzBuzz in our performance tests. The ProducerBarrier was always a one-to-one relationship with the RingBuffer so for ease of use its behaviour has been merged into the RingBuffer. This allows direct publishing into the RingBuffer. DSL Wizard The most complex part of using the Disruptor is the setting up of the dependency graph of EventP