Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [concurrency]

In computer science, concurrency is a property of systems in which multiple computations can be performed in overlapping time periods. The computations may be executing on multiple cores in the same chip, preemptively time-shared threads on the same processor, or executed on physically separated processors.

1617 votes
41 answers
396k views

What is the difference between concurrency and parallelism?

What is the difference between concurrency and parallelism?
StackUnderflow's user avatar
1507 votes
24 answers
1.2m views

How do I use threading in Python?

I would like a clear example showing tasks being divided across multiple threads.
albruno's user avatar
  • 15.2k
1334 votes
19 answers
892k views

What is a race condition?

When writing multithreaded applications, one of the most common problems experienced is race conditions. My questions to the community are: What is the race condition? How do you detect them? How do ...
bmurphy1976's user avatar
  • 30.6k
1198 votes
16 answers
1.0m views

Collection was modified; enumeration operation may not execute

I can't get to the bottom of this error, because when the debugger is attached, it does not seem to occur. Collection was modified; enumeration operation may not execute Below is the code. This is a ...
cdonner's user avatar
  • 37.5k
983 votes
26 answers
382k views

When and how should I use a ThreadLocal variable?

When should I use a ThreadLocal variable? How is it used?
user avatar
975 votes
10 answers
491k views

What is a mutex?

A mutex is a programming concept that is frequently used to solve multi-threading problems. My question to the community: What is a mutex and how do you use it?
bmurphy1976's user avatar
  • 30.6k
700 votes
11 answers
327k views

Why there is no ConcurrentHashSet against ConcurrentHashMap

HashSet is based on HashMap. If we look at HashSet<E> implementation, everything is been managed under HashMap<E,Object>. <E> is used as a key of HashMap. And we know that HashMap ...
Talha Ahmed Khan's user avatar
695 votes
13 answers
145k views

Is JavaScript guaranteed to be single-threaded?

JavaScript is known to be single-threaded in all modern browser implementations, but is that specified in any standard or is it just by tradition? Is it totally safe to assume that JavaScript is ...
Egor Pavlikhin's user avatar
670 votes
10 answers
394k views

What is the difference between lock, mutex and semaphore?

I've heard these words related to concurrent programming, but what's the difference between lock, mutex and semaphore?
victor's user avatar
  • 6,711
653 votes
19 answers
349k views

What's the difference between ConcurrentHashMap and Collections.synchronizedMap(Map)?

I have a Map which is to be modified by several threads concurrently. There seem to be three different synchronized Map implementations in the Java API: Hashtable Collections.synchronizedMap(Map) ...
Henning's user avatar
  • 11.6k
495 votes
9 answers
134k views

NSOperation vs Grand Central Dispatch

I'm learning about concurrent programming for iOS. So far I've read about NSOperation/NSOperationQueue and GCD. What are the reasons for using NSOperationQueue over GCD and vice versa? Sounds like ...
SundayMonday's user avatar
  • 19.6k
492 votes
16 answers
296k views

Custom thread pool in Java 8 parallel stream

Is it possible to specify a custom thread pool for Java 8 parallel stream? I can not find it anywhere. Imagine that I have a server application and I would like to use parallel streams. But the ...
Lukas's user avatar
  • 14.1k
472 votes
16 answers
254k views

What is the meaning of the term "thread-safe"?

Does it mean that two threads can't change the underlying data simultaneously? Or does it mean that the given code segment will run with predictable results when multiple threads are executing that ...
Varun Mahajan's user avatar
464 votes
27 answers
445k views

How to wait for all threads to finish, using ExecutorService?

I need to execute some amount of tasks 4 at a time, something like this: ExecutorService taskExecutor = Executors.newFixedThreadPool(4); while(...) { taskExecutor.execute(new MyTask()); } //......
serg's user avatar
  • 111k
443 votes
15 answers
298k views

What is a semaphore?

A semaphore is a programming concept that is frequently used to solve multi-threading problems. My question to the community: What is a semaphore and how do you use it?
bmurphy1976's user avatar
  • 30.6k

15 30 50 per page
1
2 3 4 5
1555