thread-synchronization Questions

2

Solved

All, Referring to the question in std::lock still caused deadlock I still couldn't figure what is the problem in the below code. Can somebody please explain the problem and how to fix this? Why do...
Sniffle asked 21/11, 2019 at 10:12

6

Solved

Context I have a case where multiple threads must update objects stored in a shared vector. However, the vector is very large, and the number of elements to update is relatively small. Problem I...
Danidania asked 1/5, 2019 at 16:40

2

Solved

MSDN states that: Reads and writes of other types, including long, ulong, double, and decimal, as well as user-defined types, need not be atomic. C# 7.0 draft specification - Variables - 9.6 Atom...
Potbellied asked 15/9, 2012 at 7:8

7

Solved

If you have two threads within an application, and you don't want them to run a certain piece of code simultaneously, you can just put a lock around the piece of code, like this: lock (someObject)...
Arlinda asked 24/2, 2010 at 21:57

2

Solved

What is the difference between Interlocked.Exchange and Volatile.Write? Both methods update value of some variable. Can someone summarize when to use each of them? Interlocked.Exchange Volatile.Wr...

5

Solved

I was reading Critical Section Problem from Operating System Concepts by Peter B. Galvin. According to it 1) Progress is : If no process is executing in its critical section and some processes wi...

6

I'm trying to print numbers 1-20 with two threads: Even thread - Print only even numbers. Odd thread - print only odd numbers. I also have a lock object for synchronization. My application is ...

10

Have a scenario where multiple threads have race condition on comparison code. private int volatile maxValue; private AtomicInteger currentValue; public void constructor() { this.current = new At...
Hispaniola asked 25/1, 2021 at 16:28

2

I have the following situation: I have a lot of threads in my project, and each thread process one "key" by time. Two threads cannot process the same "key" at the same time, but...
Instil asked 18/11, 2015 at 17:31

2

I am trying to support concurrency on a hashmap that gets periodically cleared. I have a cache that stores data for a period of time. After every 5 minutes, the data in this cache is sent to the se...

5

Solved

I am trying to work around with threads in java. Though I understand that threads output are unpredictable, However was wondering if there is a way to do that. I have to implement two threads, on...
Trafficator asked 17/8, 2017 at 11:20

2

I have a Windows Forms application written in .NET 4.0. Recently, while execution some tests, I noticed that there is some problem with handles. Table below shows the results: As you can see the...
Degression asked 16/2, 2014 at 18:36

9

Solved

What's the difference between a monitor and a lock? If a lock is simply an implementation of mutual exclusion, then is a monitor simply a way of making use of the waiting time inbetween method exe...
Michaelmas asked 23/5, 2009 at 18:59

3

Solved

My question is very similar to this one : @Async prevent a thread to continue until other thread have finished Basically i need run ~ hundreds of computations in more threads. I want to run only s...
Hawsehole asked 3/11, 2012 at 6:50

3

I have this pretty straightforward piece of code that very rarely throws "System.ApplicationException : Object synchronization method was called from an unsynchronized block of code." when ReleaseM...

1

Solved

Is Kotlin ?.let thread-safe? Let's say a variable can be changed in different thread. Is using a?.let { /* */ } thread-safe? If it's equal to if (a != null) { block() } can it happen that in if it...
Rhombohedron asked 2/8, 2019 at 10:1

3

Solved

If we are in a situation with two running threads on a machine with two processors and we call Thread.yield() within one of those threads, does it stand to reason that nothing will happen (the sche...

0

I am learning about cooperation between concurrent tasks and I have got that question and a possible answer to it. I would like to make sure I understand it correctly. So to call a.wait() it is fi...
Recalcitrate asked 7/10, 2018 at 13:41

3

Solved

Below is the code where a Thread enters a synchronized block, waits for 5 seconds and then exits. I have started two Thread instances simultaneously. The expectation was one of the threads will ow...

1

Solved

Suppose a Java thread performs some I/O operation like reading a file with traditional blocking Java I/O. The question is: What is the state of the thread while waiting? I don't know if it is RUNNI...
Gosnell asked 25/2, 2018 at 0:18

2

Solved

In the PRAM model, multiple processors act synchronously to execute the same command on different sets of data. There are two types of read/write mode for each algorithm; Concurrent (Concurrent...

4

I am trying to synchronize three threads to print 012012012012.... but it is not working correctly. Each thread is assigned a number which it prints when it receives a signal from main thread. Ther...
Incorporating asked 23/7, 2014 at 13:44

5

Solved

private volatile static Singleton uniqueInstance In a singleton when using double lock method for synchronization why is the single instance declared as volatile ? Can I achieve the same fu...

3

Solved

One popular solution to the ABA problem in lock-free data structures is to tag pointers with an additional monotonically incrementing tag. struct aba { void *ptr; uint32_t tag; }; However, t...
Appointment asked 28/2, 2017 at 16:58

8

Solved

I have a doubt regarding Java Synchronization . I want to know if I have three Synchronized methods in my class and a thread acquires lock in one synchronized method other two will be locked ? I am...
Officiate asked 25/6, 2012 at 6:52

© 2022 - 2025 — McMap. All rights reserved.