Top "Multithreading" questions

For questions regarding multi-threading, the ability of a computer or a program to perform work concurrently or asynchronously by utilizing multiple concurrent streams of execution (generally referred to as threads).

How to stop a thread created by implementing runnable interface?

I have created class by implementing runnable interface and then created many threads(nearly 10) in some other class of my …

java multithreading thread-safety
When to use AtomicReference in Java?

When do we use AtomicReference? Is it needed to create objects in all multithreaded programs? Provide a simple example where …

java multithreading
What does this thread join code mean?

In this code, what does the two joins and break mean? t1.join() causes t2 to stop until t1 terminates? …

java multithreading
How do I abort/cancel TPL Tasks?

In a thread, I create some System.Threading.Task and start each task. When I do a .Abort() to kill …

c# .net multithreading task abort
Synchronization vs Lock

java.util.concurrent API provides a class called as Lock, which would basically serialize the control in order to access …

java multithreading concurrency synchronization java.util.concurrent
wait until all threads finish their work in java

I'm writing an application that has 5 threads that get some information from web simultaneously and fill 5 different fields in a …

java multithreading wait
How to terminate a thread when main program ends?

If I have a thread in an infinite loop, is there a way to terminate it when the main program …

python multithreading python-multithreading
std::unique_lock<std::mutex> or std::lock_guard<std::mutex>?

I have two use cases. A. I want to synchronise access to a queue for two threads. B. I want …

c++ multithreading c++11 mutual-exclusion stdmutex
Why use a ReentrantLock if one can use synchronized(this)?

I'm trying to understand what makes the lock in concurrency so important if one can use synchronized (this). In the …

java multithreading concurrency synchronize reentrantlock
Volatile vs Static in Java

Is it correct to say that static means one copy of the value for all objects and volatile means one …

java multithreading concurrency static volatile