thread-safety

Java GUI and threads

I have a GUI which has textarea and buttons and etc......... I have a different class which is a thread that is running constantly. I want to append text to the textarea when certain conditions are met in the thread class. In the class containing the textarea i have getter methods for the textarea. I have also declared that class(conta...

How do I use the LOCK ASM prefix to read a value?

I know how to use LOCK to thread-safely increment a value: lock inc [J]; But how do I read [J] (or any value) in a thread-safe manner? The LOCK prefix can't be used with mov. And if I do the following: xor eax, eax; lock add eax, [J]; mov [JC], eax; It raises an error on line 2. ...

C++ Singleton Threading problem

I have a C++ singleton that runs as a separate thread. This singleton is derived from a base class provided by a library and it overrides the method onLogon(...). The onLogon method is synchronous, it wants to know right away if we accept the logon attempt. Problem is we need to pass the logon information via message to a security ser...

How do I atomically read a value in x86 ASM?

I know how to atomically write a value in x86 ASM. But how do I read one? The LOCK prefix can't be used with mov. To increase a value, I am doing: lock inc dword ptr Counter How do I read Counter in a thread-safe way? ...

python dictionary is thread safe ?

Some stated that python dictionary is thread safe. Does it mean I can or cannot modified the items in a dictionary while iterating over it? ...

Synchronize access to keys stored in distributed cache (SharedCache)

In my project I am using SharedCache as a distributed caching mechanism. There are multiple instances of a service deployed in webfarm which accesses this cached data. The data which is cached is transient and can have updates. I would like to know if there is any way we can synchronize the access to the data between two or more services...

Is LinkedList thread-safe when I'm accessing it with offer and poll exclusively?

Hi, I have a linked list samples: protected LinkedList<RawDataset> samples = new LinkedList<RawDataset>(); I'm appending elements to the list in thread 1 like this: this.samples.offer(data); And I'm retrieving elements from it in a second thread like so: public RawDataset retrieveSample() { return this.samples.poll(); } Wou...

Threads and synchronisation

I've problem understanding the following piece of code:- public class SoCalledSigleton{ private final static boolean allDataLoaded = SoCalledSigleton(); private SoCalledSigleton(){ loadDataFromDB(); loadDataFromFile(); loadDataAgainFromDB(); } } Is this piece of code thread safe? If not t...

Is Blackberry's SimpleDateFormat thread safe?

Is the BlackBerry version of SimpleDateFormat, net.rim.device.api.i18n.SimpleDateFormat thread safe? I know that java.text.SimpleDateFormat is not but there is no mention if net.rim.device.api.i18n.SimpleDateFormat is thread safe or not. Should we assume if it is not stated then it is not thread safe? ...

Setting sync object in WPF

Where do i get the ISynchronizeInvoke so i can sync against UI thread? System.Timers.Timer gTimer; gTimer.SynchronizingObject; ...

IN SQL Server is CLR Threadsafe

I have an interface in CLR between SQL Server and the Exchange Web Services to Sync and send emails between applications. In testing this it works(ed) without any problems; we are seeing sporadic issues in the production environment where longer web service task appear to be have overlapped. My question is very simple and I cant decide ...

Is Silverlight's CollectionViewSource thread-safe?

I am trying to figure this out, given the following code, does the Refresh() need to occur on the UI thread? It seems to work, and I am wondering if the CollectionViewSource is actually a thread-aware / safe object? It definately has properties and methods to support calling on the correct thread, just not sure if that is left up to th...

Multi-threading guidelines: Can't remember my source

Hi, I'm trying to track down the source of a particular piece of coding advice I once read. I'm currently working with a class that has a lot of threading around a single shared resource, controlled by a mutex. I just spent a week trying to debug the damn code, because it's difficult to spot sub-functions which don't self-lock, and...

How to disable thread safety in PHP?

I am using some software that requires me to have thread safety disabled. I am working on a Windows server. From what I've read elsewhere, I can't just configure this in the .ini file. Is this true? If so, how would I compile it so that thread safety is turned off? Thanks! ...

Is atomic CAS required when setting a boolean to true

I have class where a bool is access concurrently. However in my case it is only initialized to false once in the constructor, and after that it set to false. Am i correct to believe that even though a race might occur the result will be valid and defined? Since the entire bool doesn't have to be written to inorder for "!isStopping_" to ...

Atomically locking multiple files

What is the best way to atomically lock multiple files? One possibility I've thought of is a simple .lock file in the directory (I'm only protected from other instances of my program; I'm not necessarily trying to thwart other programs from disrespecting the lock.) However, everything I've learned about thread-safety screams "bad idea!" ...

why java.util.HashMap.getEntry can block my program ?

Hi, everyone, my program had been blocked , I used the jstack commander to analyze, the following thread took the lock "0x0000000603f02ae0" , and others threads couldn't fetch the lock. I had waited at least one hour, but the thread didn't unlock , my question is why the thread'state is RUNNING, and stop at java.util.HashMap.getEntry(Has...

Writing a thread safe modular counter in Java

Full disclaimer: this is not really a homework, but I tagged it as such because it is mostly a self-learning exercise rather than actually "for work". Let's say I want to write a simple thread safe modular counter in Java. That is, if the modulo M is 3, then the counter should cycle through 0, 1, 2, 0, 1, 2, … ad infinitum. Here's one...

java call function from multiple threads not declared as thread safe

Hi, There is a JDK function that, although the javadocs does not declare it as thread-safe, from looking at the code in Google, it seems that I could get the result I want by calling it from multiple threads without undesirable side-effects, since the function uses mainly stack variables. So it does not matter if it has synchronized blo...

Problem with running WebService in separate thread in Delphi

I have never asked questions in any community as I always solved problems by myself or could find them online. But with this one I came to dead end and need Help! To make it very clear – I converted a simple app, found elsewhere to make it use a Tthread object. The idea is simple – the app checks online using webservice, through THTTPRIO...