Author Archives: Stanislav_Panteleev

Java.Reactive.Explain the concept of data flows in reactive programming

In reactive programming, a data flow is like a pipeline where data travels through a series of transformations and reactions — all done in a declarative, non-blocking, and asynchronous way. You don’t “call” data; it comes to you. You set … Continue reading →

Posted in Без рубрики | Comments Off on Java.Reactive.Explain the concept of data flows in reactive programming

Java.Reactive.What is reactive programming and how is it different from procedural programming?

Reactive Programming is a programming paradigm focused on asynchronous data streams and the propagation of change. It’s all about reacting to data as it comes in — like events, user interactions, or data updates — and building systems that respond … Continue reading →

Posted in Без рубрики | Comments Off on Java.Reactive.What is reactive programming and how is it different from procedural programming?

Java.Multithreading.Write a simple multi-threaded bounded buffer using ReentrantLock.

Absolutely, Stanley! 💡 Let’s implement a simple, thread-safe, bounded buffer using: ✅ ReentrantLock for thread safety ✅ Condition variables for blocking and coordination ✅ Classic producer-consumer pattern 🎯 Goal Block put() when buffer is full Block take() when buffer is … Continue reading →

Posted in Без рубрики | Comments Off on Java.Multithreading.Write a simple multi-threaded bounded buffer using ReentrantLock.

Java.Multithreading.Write a simple multi-threaded bounded buffer using synchronized.

📦 What Is a Bounded Buffer? A bounded buffer is a fixed-size queue that: Allows producers to put() items. Allows consumers to take() items. Blocks producers if the buffer is full. Blocks consumers if the buffer is empty. ✅ Key … Continue reading →

Posted in Без рубрики | Comments Off on Java.Multithreading.Write a simple multi-threaded bounded buffer using synchronized.

Java.Multithreading.Write a thread-safe implementation of a class with a non-blocking BigInteger next() method that returns the elements of the sequence: [1, 2, 4, 8, 16, …].

✅ Requirements Thread-safe: Safe for concurrent calls from multiple threads. Non-blocking: No synchronized, no locks. Returns: BigInteger values doubling each time → 1, 2, 4, 8, 16, …

Posted in Без рубрики | Comments Off on Java.Multithreading.Write a thread-safe implementation of a class with a non-blocking BigInteger next() method that returns the elements of the sequence: [1, 2, 4, 8, 16, …].

Java.Multithreading.Write a minimal non-blocking ArrayList (only four methods – add(), get(), remove(), size()).

💪 Writing a non-blocking ArrayList is a tricky but fun task — because arrays require index-based coordination, which is much harder to do without locks than a linked structure like a stack. But let’s take it step by step and … Continue reading →

Posted in Без рубрики | Comments Off on Java.Multithreading.Write a minimal non-blocking ArrayList (only four methods – add(), get(), remove(), size()).

Java.Multithreading.Write a minimal non-blocking stack (only two methods – push() and pop()) using Semaphore.

✅ Minimal Blocking Stack Using Semaphore This stack: Uses a Deque to store elements Uses a Semaphore to track available elements Is thread-safe, but not lock-free (uses internal synchronization) 🧪 Example Usage: 🔍 How It Works: items.acquire() blocks if the … Continue reading →

Posted in Без рубрики | Comments Off on Java.Multithreading.Write a minimal non-blocking stack (only two methods – push() and pop()) using Semaphore.

Java.Multithreading.Write a minimal non-blocking stack (only two methods – push() and pop()).

🔥 Let’s write a minimal non-blocking stack using lock-free programming with CAS (Compare-And-Swap) operations, leveraging AtomicReference.

Posted in Без рубрики | Comments Off on Java.Multithreading.Write a minimal non-blocking stack (only two methods – push() and pop()).

Java.Multithreading.Given 3 threads T1, T2 and T3? How to implement execution in sequence T1, T2, T3?

🔄 Controlling the execution order of threads (T1 → T2 → T3) is a classic multithreading problem, and there are several ways to achieve it — depending on your style and needs. ✅ Goal: Run Threads in This Exact Order

Posted in Без рубрики | Comments Off on Java.Multithreading.Given 3 threads T1, T2 and T3? How to implement execution in sequence T1, T2, T3?

Java.Multithreading.List the principles you follow in multithreaded programming?

✅ 1. Minimize Shared Mutable State The best way to avoid concurrency issues is not to share data at all. Prefer immutable objects Use thread-local storage when needed Copy-on-write or defensive copying strategies

Posted in Без рубрики | Comments Off on Java.Multithreading.List the principles you follow in multithreaded programming?