thread-safety

Thread-safe C++ stack

I'm new to C++ and am writing a multi-threaded app whereby different writers will be pushing objects onto a stack and readers pulling them off the stack (or at least pushing the pointer to an object).. Are there any structures built-into C++ which can handle this without adding locking code etc.? If not, what about the Boost libraries? ...

C++ new operator thread safety in linux and gcc 4

Soon i'll start working on a parallel version of a mesh refinement algorithm using shared memory. A professor at the university pointed out that we have to be very careful about thread safety because neither the compiler nor the stl is thread aware. I searched for this question and the answer depended on the compiler (some try to be so...

Static dictionary in .Net Thread safety

Reading msdn documentation for dictionaries it says : "Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe." Those this mean that with a dictionary such as this : static object syncObject = new object(); static Dictionary<string,MyObject> mydictionary= ...

C++ Thread-Safe Map

Does anyone know where I can find an implimentation that wraps an STL map and makes it thread safe? When I say thread safe I mean that it offers only serial access to the map, one thread at a time. Optimally, this map should use only STL and or boost constructs. ...

thread with multiple parameters

Does anyone know how to pass multiple parameters into a Thread.Start routine? I thought of extending the class, but the C# Thread class is sealed. Here is what I think the code would look like: ... Thread standardTCPServerThread = new Thread(startSocketServerAsThread); standardServerThread.Start( orchestrator, initializeMembe...

Is a lock (wait) free doubly linked list possible?

Asking this question with C# tag, but if it is possible, it should be possible in any language. Is it possible to implement a doubly linked list using Interlocked operations to provide no-wait locking? I would want to insert, add and remove, and clear without waiting. ...

Is this Python producer-consumer lockless approach thread-safe?

I recently wrote a program that used a simple producer/consumer pattern. It initially had a bug related to improper use of threading.Lock that I eventually fixed. But it made me think whether it's possible to implement producer/consumer pattern in a lockless manner. Requirements in my case were simple: One producer thread. One consume...

Threadsafe vs re-entrant

Recently, I asked a question, with title as "Is malloc thread safe?", and inside that I asked, "Is malloc re-entrant?" I was under the impression that all re-entrant are thread-safe. Is this assumption wrong? ...

What are the common mistakes that causes the code in Java is not thread safe?

Duplicate: What is the most frequent concurrency problem you’ve encountered in Java? I've been thinking of list of common programming mistakes/pitfalls that causes the code in Java is not thread safe. Here are the common ones that I encountered in the code through the recent years of Java development. Using non-static fields within ...

Is SQLite.Net thread-safe?

I'm asking about the .Net implementation - System.Data.SQLite. Are there guidelines to using it in a thread-safe manner? I know SQLite itself can be compiled with or without thread safety - but how was System.Data.SQLite compiled? ...

Java : Is ServerSocket.accept threadsafe ?

For a project in school, we are making a multithreaded server in Java 5.0. This project is centered on the concurrence aspect of a server. We have some threads dedicated to treating the requests. To do so, they have a call to a ServerSocket.accept() to accept new connections. Our choice was to start a bunch of them and let them treat th...

Is accessing to different indexes of a TObjectList thread safe?

I have a TObjectList that needs to be processed by several threads. Since internally TObjectList inherits from TList and TList implements its internals as an array I wonder: Is it thread safe to access the array from different threads as long as we access different indexes? For example, having a TObjectList called myObjectList: start ...

Best Data Structure for this Multithreaded Use Case: Is Intrusive List good?

I need to design a data structure that supports the following operations: search element in the data structure based on a key that is an interval. For example the value within interval 1-5 may be 3, from 6-11 may be 5 and so on. The intervals are contiguous and there is no overlap between them. find previous and next interval - this i...

How many CRITICAL_SECTIONs can I create?

Is there a limit to the number of critical sections I can initialize and use? My app creates a number of (a couple of thousand) objects that need to be thread-safe. If I have a critical section within each, will that use up too many resources? I thought that because I need to declare my own CRITICAL_SECTION object, I don't waste kerne...

interlocked operation on unanligned data

Hi; The win32 interlocked functions provide a mecanism for atomic operation on data. They are supposed to be thread-safe and multiprocessor-safe. What happen if the data is not aligned? the interlocked operations are still atomic? Ex.: incrementing a integer that is not aligned. Ty ...

Shared XElement as SiteMap

I have a custom CMS in which I use an static XElement as the site map. When updates occur to the map, I am synchronizing the writer threads, but am doing nothing with the readers, just allowing them to grab the XElement when they need it. In testing, I thought that if I was enumerating the XElement from a reader thread, while I update...

Is the C# '??' operator thread safe?

Everyone knows that this is not thread safe: public StringBuilder Builder { get { if (_builder != null) _builder = new StringBuilder(); return _builder; } } What about this? public StringBuilder Builder { get { return _builder ?? (_builder = new StringBuilder()); } } ...

Thread Safety of .NET Encryption Classes?

I have a high-level goal of creating a static utility class that encapsulates the encryption for my .NET application. Inside I'd like to minimize the object creations that aren't necessary. My question is: what is the thread-safety of the classes which implement symmetric encryption within the .NET Framework? Specifically System.Secur...

Should my Scala actors' properties be marked @volatile?

In Scala, if I have a simple class as follows: val calc = actor { var sum = 0 loop { react { case Add(n) => sum += n case RequestSum => sender ! sum } } } Should my field sum be marked @volatile? Whilst the actor is logically single-threaded (i.e. the messages are processed sequentially), the...

C#: Thread-safe events

Is the implementation below thread-safe? If not what am I missing? Should I have the volatile keywords somewhere? Or a lock somewhere in the OnProcessingCompleted method? If so, where? public abstract class ProcessBase : IProcess { private readonly object completedEventLock = new object(); private event EventHandler<ProcessComp...