thread-safety Questions
1
cppreference is explicit about calling std::shared_future<T>::wait from multiple threads:
Calling wait on the same std::shared_future from multiple threads is not safe; the intended use is f...
Blotter asked 23/3, 2021 at 14:27
2
Solved
I have a simple object
@Data
@Builder
public class Address {
private Long id;
private String street;
}
I make delombok of @Builder annotation and I see next code generated
@Data
public class ...
Faulk asked 8/3, 2018 at 8:28
5
I want to use a global variable,
Init it once.
having a thread safe access.
Can someone share an example please?
Crater asked 20/2, 2013 at 11:57
2
I have the following class that is shared between multiple consumers (using producer/consumer methodology). My question involves the methods called on this class. Do I need to implement locks or is...
Miosis asked 26/7, 2017 at 3:10
8
I'm making my application thread-safe. One of the steps is to synchronize access or eliminate usages of global variables. I'm using Visual Studio. I can't find any good way to find all global varia...
Truda asked 15/9, 2011 at 11:45
5
Solved
Are C/C++ fundamental types, like int, double, etc., atomic, e.g. threadsafe?
Are they free from data races; that is, if one thread writes to an object of such a type while another thread reads fr...
Warila asked 5/2, 2016 at 14:4
8
Solved
I've heard about this happening in non thread-safe code due to improperly constructed objects but I really don't have the concept down, even after reading about in in Goetz's book. I'd like to soli...
Nonmoral asked 19/10, 2009 at 12:30
2
Solved
I'm late to the party, but I recently learned about SemaphoreSlim:
I used to use lock for synchronous locking, and a busy boolean for asynchronous locking. Now I just use SemaphoreSlim for everythi...
Imamate asked 21/11, 2022 at 17:39
1
I am writing a library that makes extensive use of threading and would likely benefit from virtual threads in Java 21+.
However, the library must also work for earlier versions of Java (possibly ba...
Carltoncarly asked 20/3, 2024 at 9:47
1
According to the thread-sanitizer docs:
ThreadSanitizer uses more real memory than a native run. At the default settings the memory overhead is 5x plus 1Mb per each thread. Settings with 3x (les...
Holey asked 8/1, 2019 at 9:44
18
Odd even number printing using thread I came across this question and wanted to discuss solution in C++ . What I can think of using 2 binary semaphores odd and even semaphore. even semaphore initia...
Hypha asked 1/2, 2013 at 6:48
14
Solved
What are some recommended approaches to achieving thread-safe lazy initialization? For instance,
// Not thread-safe
public Foo getInstance(){
if(INSTANCE == null){
INSTANCE = new Foo();
}
ret...
Vive asked 28/11, 2011 at 14:57
5
Solved
Suppose I have this Python code:
from itertools import count, tee
original = count() # just an example, can be another iterable
a, b = tee(original)
The question is, will there be any problem if...
Sepulchral asked 15/7, 2011 at 6:49
2
What is the thread safe way to dispose a lazy-initialized object in C#? Suppose I have the following Lazy construct:
Lazy<MyClass> lazy = new Lazy<MyClass>(() => MyClass.Create(), t...
Babbie asked 19/6, 2018 at 19:15
21
Solved
I have a webapp that I am in the middle of doing some load/performance testing on, particularily on a feature where we expect a few hundred users to be accessing the same page and hitting refresh a...
Pampero asked 25/9, 2008 at 15:27
3
Solved
I'm curious about thread safety for hashes in Ruby. Running the following from the console (Ruby 2.0.0-p247):
h = {}
10.times { Thread.start { 100000.times {h[0] ||= 0; h[0] += 1;} } }
returns
...
Onomasiology asked 26/3, 2014 at 22:36
5
Solved
I am currently working with AForge, and have an on new frame event that posts the frame, as a bitmap, into a picturebox. 90% of the time it works great... UNLESS I fiddle with something on the winf...
Gabardine asked 17/4, 2013 at 13:13
6
I'm looking for a way to do asynchronous and thread-safe logging in my C++ project, if possible to one file. I'm currently using cerr and clog for the task, but since they are synchronous, executio...
Lattimore asked 28/5, 2010 at 15:24
6
Solved
Everything I've read about volatile says it's never safe, but I still feel inclined to try it, and I haven't seen this specific scenario declared unsafe.
I have a separate thread that renders a sc...
Stirrup asked 25/2, 2013 at 18:41
10
Solved
I have a JUnit test that I want to wait for a period of time synchronously. My JUnit test looks like this:
@Test
public void testExipres(){
SomeCacheObject sco = new SomeCacheObject();
sco.putWit...
Falbala asked 10/4, 2013 at 23:53
2
Condition variables should have have a single order with respect to notify() and unlock_sleep() (an imaginary function call used within wait() where the mutex is unlocked and the thread sleeps as o...
Furie asked 29/10, 2017 at 18:14
2
Solved
Coding in Kotlin, want a thread-safe List as described here: java concurrent Array List access
It seems Collections.kt does not have this function. Are Kotlin's mutable lists already threadsafe ? ...
Tetratomic asked 30/5, 2018 at 22:19
2
Solved
I have a web API service that will accept many concurrent requests by different clients accessing two SQL Server databases, all the controllers (around 65) have a BaseApiController, find below the ...
Aalii asked 28/5, 2016 at 4:22
8
Solved
I have the following class.
class Test{
public HashSet<string> Data = new HashSet<string>();
}
I need to change the field "Data" from different threads, so I would like some opinion...
Untitled asked 20/9, 2013 at 17:57
2
I have a multithreaded program for which I'd like to use the Trace.WriteLine, and redirect the output to a text file:
_LogTracer = new System.Diagnostics.TextWriterTraceListener(logPath);
Trace.A...
Pumice asked 27/10, 2015 at 7:48
1 Next >
© 2022 - 2025 — McMap. All rights reserved.