All fields

“Concurrency & Threads” in Information Technology

52 questions across 7 technologies.

Information Technology

52 questions in 7 technologies

#QuestionTechnologyTopicLevel
1How does Java's virtual threads feature (Project Loom, finalized in Java 21) fundamentally change the thread-per-task model for high-concurrency applications, and how do they differ from traditional platform threads? Java › Concurrency & ThreadsJavaConcurrency & ThreadsAdvanced
2What is a race condition, and how does it differ conceptually from a deadlock as two distinct categories of concurrency bugs? Java › Concurrency & ThreadsJavaConcurrency & ThreadsIntermediate
3What are the two primary ways to create a thread in Java (extending Thread versus implementing Runnable), and which is generally preferred? Java › Concurrency & ThreadsJavaConcurrency & ThreadsBeginner
4What is the difference between calling Thread.start() and Thread.run() directly, and why is calling run() directly a common beginner mistake? Java › Concurrency & ThreadsJavaConcurrency & ThreadsBeginner
5What is the synchronized keyword, and how does it use Java's intrinsic (monitor) locks to prevent race conditions on shared mutable state? Java › Concurrency & ThreadsJavaConcurrency & ThreadsIntermediate
6What is the ExecutorService framework, and why is it generally preferred over manually creating and managing individual Thread objects? Java › Concurrency & ThreadsJavaConcurrency & ThreadsIntermediate
7What causes a deadlock in multithreaded Java code, and what is the classic "lock ordering" strategy for preventing it? Java › Concurrency & ThreadsJavaConcurrency & ThreadsIntermediate
8What are the atomic classes in java.util.concurrent.atomic (AtomicInteger, AtomicLong, AtomicReference), and how do they achieve thread-safe operations without traditional locking? Java › Concurrency & ThreadsJavaConcurrency & ThreadsIntermediate
9What is thread starvation, and how can thread priority misuse or unfair lock scheduling contribute to it? Java › Concurrency & ThreadsJavaConcurrency & ThreadsIntermediate
10What is the difference between wait()/notify()/notifyAll() (Object's intrinsic monitor methods) and the newer java.util.concurrent tools, and why are the older methods considered error-prone? Java › Concurrency & ThreadsJavaConcurrency & ThreadsIntermediate
11How does java.util.concurrent's ReentrantLock differ from the synchronized keyword, and what additional capabilities does it provide (tryLock, fairness, interruptible locking)? Java › Concurrency & ThreadsJavaConcurrency & ThreadsAdvanced
12How do CompletableFuture's composition methods (thenApply, thenCompose, thenCombine) enable building asynchronous pipelines, and what's the difference between thenApply and thenCompose? Java › Concurrency & ThreadsJavaConcurrency & ThreadsAdvanced
13How does the Java Memory Model's happens-before relationship formally define when changes made by one thread are guaranteed to be visible to another thread, and what role does the volatile keyword play? Java › Concurrency & ThreadsJavaConcurrency & ThreadsAdvanced
14How would you use CountDownLatch, CyclicBarrier, and Semaphore for different thread coordination scenarios, and what distinguishes their use cases? Java › Concurrency & ThreadsJavaConcurrency & ThreadsAdvanced
15How would you diagnose a suspected thread deadlock in a running production JVM using a thread dump, and what specific information in the dump reveals the deadlock? Java › Concurrency & ThreadsJavaConcurrency & ThreadsAdvanced
16How do you safely update collections bound to the UI from background threads? .NET MAUI › Concurrency & Threading.NET MAUIConcurrency & ThreadingAdvanced
17How do you safely update collections bound to the UI from background threads? .NET MAUI › Concurrency & Threading.NET MAUIConcurrency & ThreadingAdvanced
18How do you protect shared mutable state from race conditions when using multiple threads, using threading.Lock? Python › Concurrency (asyncio/threading/multiprocessing)PythonConcurrency (asyncio/threading/multiprocessing)Intermediate
19How do you share data between processes using multiprocessing, given that separate processes don't share memory the way threads do? Python › Concurrency (asyncio/threading/multiprocessing)PythonConcurrency (asyncio/threading/multiprocessing)Advanced
20How would you implement a producer-consumer pattern combining a thread-safe queue.Queue with multiple worker threads? Python › Concurrency (asyncio/threading/multiprocessing)PythonConcurrency (asyncio/threading/multiprocessing)Advanced
21How does the JVM's tri-color marking algorithm (used by concurrent garbage collectors like G1) work to identify reachable objects while application threads continue running concurrently, and what problem does a write barrier solve in this context? Java › Garbage CollectionJavaGarbage CollectionAdvanced
22How do coroutines differ from threads? C++ › CoroutinesC++CoroutinesBeginner
23What is the difference between concurrency and parallelism, and which one does Node.js's event loop actually provide by default? Node.js › Event Loop & Non-blocking IONode.jsEvent Loop & Non-blocking IOBeginner
24How would you implement a thread-safe caching decorator that correctly handles concurrent calls from multiple threads? Python › DecoratorsPythonDecoratorsAdvanced
25What is the difference between how Node.js handles I/O-bound concurrency versus CPU-bound work, and why does this distinction shape Node.js's ideal use cases? Node.js › Event Loop & Non-blocking IONode.jsEvent Loop & Non-blocking IOAdvanced
26How does Node.js achieve high concurrency for I/O-bound workloads despite running JavaScript on a single main thread? Node.js › Node.js Fundamentals & Runtime ArchitectureNode.jsNode.js Fundamentals & Runtime ArchitectureAdvanced
27What is the Singleton pattern, and how would you implement a thread-safe Singleton in Java? Java › Design Patterns in JavaJavaDesign Patterns in JavaBeginner
28Why was the modern java.time API (introduced in Java 8) created to replace the legacy Date and Calendar classes, and what specific problems did the old classes have? Java › Java Date & Time API (java.time)JavaJava Date & Time API (java.time)Beginner
29What is the difference between the async and await keywords in C#, and how do they work together? C# › Asynchronous ProgrammingC#Asynchronous ProgrammingBeginner
30What are the phases of class loading (loading, linking, initialization), and what specifically happens during each? Java › Class Loading & Bytecode VerificationJavaClass Loading & Bytecode VerificationIntermediate
31What is the difference between fail-fast and fail-safe iterators in the Collections Framework, and which collections use each? Java › Collections FrameworkJavaCollections FrameworkIntermediate
32What is the purpose of the Deque interface, and how does it unify both stack (LIFO) and queue (FIFO) behavior in a single interface? Java › Collections FrameworkJavaCollections FrameworkIntermediate
33What is the purpose of the Collections utility class's synchronization wrappers (Collections.synchronizedList(), etc.), and how do they differ from genuinely concurrent collections like ConcurrentHashMap? Java › Collections FrameworkJavaCollections FrameworkIntermediate
34What is the difference between a stop-the-world (STW) GC pause and a concurrent GC phase, and why can't garbage collection be made entirely concurrent with zero pauses? Java › Garbage CollectionJavaGarbage CollectionIntermediate
35What is a local class's access to effectively-final local variables, and how does this same rule (and the underlying reason for it) apply identically to anonymous classes and lambdas? Java › Inner Classes & Anonymous ClassesJavaInner Classes & Anonymous ClassesIntermediate
36How do you parse and format date/time values using DateTimeFormatter, and how does this replace the older, notoriously thread-unsafe SimpleDateFormat class? Java › Java Date & Time API (java.time)JavaJava Date & Time API (java.time)Intermediate
37How would you make an asynchronous, non-blocking HTTP request using HttpClient's sendAsync() method, and how does the returned CompletableFuture integrate with the rest of an asynchronous pipeline? Java › Java Networking & HTTP ClientJavaJava Networking & HTTP ClientIntermediate
38How would you efficiently copy, resize, or merge large arrays in Java, and what are the performance trade-offs between System.arraycopy(), Arrays.copyOf(), and manual loops? Java › Arrays & Multidimensional ArraysJavaArrays & Multidimensional ArraysAdvanced
39How does a thread context ClassLoader (Thread.currentThread().getContextClassLoader()) solve the problem of a core JDK class needing to load an application-provided implementation class, given parent delegation normally prevents this? Java › Class Loading & Bytecode VerificationJavaClass Loading & Bytecode VerificationAdvanced
40How does the Collections Framework's fail-fast modCount mechanism actually work internally, and why is it described as "best-effort" rather than a strict guarantee? Java › Collections FrameworkJavaCollections FrameworkAdvanced
41How would you implement the Observer pattern in Java, and how does it compare to using the built-in PropertyChangeSupport or a reactive streams library? Java › Design Patterns in JavaJavaDesign Patterns in JavaAdvanced
42How does Java implement enums under the hood at the bytecode level (extending java.lang.Enum), and what makes them inherently thread-safe and serialization-safe as singletons? Java › EnumsJavaEnumsAdvanced
43How does a lambda expression capture variables from its enclosing scope, and why must captured local variables be effectively final? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesAdvanced
44How would you implement memoization (caching function results) as a higher-order function wrapping an existing Function, and what thread-safety considerations apply for a memoized function used concurrently? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesAdvanced
45How would you diagnose a memory leak in a Java application (where memory usage grows unboundedly despite garbage collection running) using heap dump analysis, and what common patterns cause 'leaks' in a garbage-collected language? Java › Garbage CollectionJavaGarbage CollectionAdvanced
46How does java.nio's Channel and Buffer abstraction differ fundamentally from the classic java.io Stream model, and what specific capability does this enable for non-blocking I/O? Java › I/O & NIOJavaI/O & NIOAdvanced
47How would you implement asynchronous file I/O using AsynchronousFileChannel, and how does this differ from both the classic blocking java.io model and NIO's Selector-based non-blocking channels? Java › I/O & NIOJavaI/O & NIOAdvanced
48How would you implement file locking (using FileLock) to coordinate exclusive access to a shared file across multiple processes, and what are the platform-specific reliability caveats? Java › I/O & NIOJavaI/O & NIOAdvanced
49How does the Instant class represent a point in time, and how does it differ fundamentally from ZonedDateTime in terms of what it actually represents and how it should be used? Java › Java Date & Time API (java.time)JavaJava Date & Time API (java.time)Advanced
50What is the difference between Task and Thread in C#, and when would you deliberately choose one over the other? C# › Asynchronous ProgrammingC#Asynchronous ProgrammingAdvanced
51What is ValueTask<T> in C#, and when does it actually provide a meaningful performance benefit over Task<T>? C# › Asynchronous ProgrammingC#Asynchronous ProgrammingAdvanced
52How does async/await work under the hood in C#, and what specifically happens when execution reaches an 'await'? C# › Asynchronous ProgrammingC#Asynchronous ProgrammingAdvanced