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

All Questions

1 vote
0 answers
19 views

How do I iterate over a sublist of a SynchronizedList in Java?

What kind of synchronization should I use to iterate over a sublist returned from a SynchronizedList as a result of subList() method invocation? The documentation for Collections.synchronizedList() ...
peremeykin's user avatar
0 votes
1 answer
73 views

How can I formally verify the correctness of my WaitGroup implementation in C++?

Description I've implemented a WaitGroup in C++ assuming that: user must ensure that the counter value does not drop below zero. WaitGroup can be reused. Below is my code: class WaitGroup { public: ...
NJrslv's user avatar
  • 25
-1 votes
1 answer
55 views

Is sync.Map LoadOrStore subject to race conditions?

I'm using sync.Map's LoadOrStore method in Go. I'm trying to understand if there could be a race condition leading to multiple evaluations of the value creation function. I'm trying to understand if ...
Zanko's user avatar
  • 4,554
0 votes
0 answers
58 views

How many go routines will be created at runtime?

In an interview today, I got a problem to write a program with 2 goroutines to generate even and odd sequence and synchronize them to print the sequence of number. Later, I was asked how many routines ...
Eshant Gupta's user avatar
0 votes
0 answers
17 views

Fairness Issue in Readers/Writers Problem Solution: Violation of Bounded Waiting

One basic problem with the Readers/Writers problem solution provided was that it was biased in favour of readers, i.e once a reader enters the system it allows other readers to join regardless of if a ...
Shafin's user avatar
  • 1
0 votes
1 answer
129 views

Weird race-condition in java ThreadPoolExecutor

I`m trying to make an api-checking app that must send requests asynchronously using the pool of bots while termination date is not reached. On startup creates a final List<Bot> is created and ...
IndependenceCR's user avatar
0 votes
0 answers
36 views

Thread counter Synchronization issue

I am trying to learn Multithreading techniques. I tried to implement the synchronized behaviour to increment the counter. I am using two variables one is AtomicInteger and another one with normal ...
Nitin Gangwar's user avatar
0 votes
1 answer
69 views

Is there a race in the following concurrent code

Let's say I have different implementations of an interface: interface IDataManager { Integer GetData(string key); // returns null if data is not found void UpdateData(string key, int value); } ...
Alexander Zveniev's user avatar
0 votes
1 answer
384 views

What is the difference between a semaphore and an atomic int?

I mean not from the point of view of there interfaces in C++, but from OS side, what real difference between these concepts. Tried to google it, but on different resources i just found only very ...
Dzmitry Kulik's user avatar
-1 votes
1 answer
40 views

Is optimization to move block inside both the block of a if-else branch correct?

Warning(Pseudocode) Suppose we have a kernel : def kernel(array): a = get_global_id(0) if a > 1: array[0] = 10 barrier(LOCAL_MEM_FENCE) Is it wrong for the code to get optimized ...
Rohan Jha's user avatar
0 votes
1 answer
47 views

Not able understand tryLock method while executing program

I was learning Java concurrency and trying ReentrantLock class methods. While trying tryLock() method and running sample program, it's not working as it should. By definition if lock is available, ...
vitaminC's user avatar
0 votes
1 answer
85 views

sync.Cond not woking properly with multiple goroutines

I am trying to print in multiple go routines only when sync.Cond does Broadcasts but the go routines are deadlocking. Is there any way the below code can be improved and are there any ways to identify ...
cool_fire's user avatar
0 votes
1 answer
74 views

How to use Interlocked.CompareExchange as an inter-process lock?

I'm obviously doing something wrong here. I always get different number running this code: var counter = new ConcurrentCounter(); var count = counter.Count(); Console.WriteLine(count); public class ...
user1576055's user avatar
1 vote
0 answers
102 views

File Based Locking vs In-Memory Locking

So I know what locks are and how they are used. I was messing around with Lucene and noticed that it uses a file (.e.g. write.lock) rather than an in-memory object to synchronize the multiple threads ...
David's user avatar
  • 398
0 votes
1 answer
49 views

Is synchronization needed when sharing a List<T> inside of a method in Parallel.ForEach?

I just saw following code snippet: public List<string> ProcessText(List<student> students) { List<student> result = new(); Parallel.ForEach(students, (st) => { ...
pmn's user avatar
  • 2,237

15 30 50 per page
1
2 3 4 5
40