Let's say that I have a module that has a Queue in it.
For other entities to Enqueue, they must go through a function:
public sub InsertIntoQueue(Obj)
MyQueue.Enqueue(Obj)
end sub
If I have multiple threads running and they want to call InsertIntoQueue(), is this considered thread safe?
I am under the impression that there is on...
I am writing an app. There are plugins which DL resource from the net. If the user would like to quit i would not like any DLs to start but i would like DLs in progress to continue until done. After they stop i would gracefully quit.
How do i find out if a thread is in a middle of a DL or just sleeping? The actual download resource func...
Hi
I am trying to run multiple tasks, each task access the database, and I am trying to run the tasks into separate execution wires.
I played around, tried allow_concurrency which I have set to true, or config.thread_safe! but it I get un-deterministic errors, for example sometimes a class is missing, or a constant ...
here is some c...
I've seen a few implementations of popen()/pclose(). They all used a static list of pids, and no locking:
static int *pids;
static int fds;
if (!pids) {
if ((fds = getdtablesize()) <= 0)
return (NULL);
if ((pids = malloc(fds * sizeof(int))) == NULL)
return (NULL);
memset(pids, 0, fds * sizeof(int));
}
O...
I've written a class and many unit test, but I did not make it thread safe. Now, I want to make the class thread safe, but to prove it and use TDD, I want to write some failing unit tests before I start refactoring.
Any good way to do this?
My first thought is just create a couple threads and make them all use the class in an unsafe w...
First let's look at the utility class (most javadoc has been removed to simply the example):
public class ApplicationContextUtils {
/**
* The application context; care should be taken to ensure that 1) this
* variable is assigned exactly once (in the
* {@link #setContext(ApplicationContext)} method, 2) the context is...
Hi I am using the ADO.NET entity framework for the first time and the staticcode analysis is suggesting I change the following method to a static one as below.
My question is simple, is this thread safe?
public static void InsertUserDetails(UserAccount userAccount)
{
using (KnowledgeShareEntities entities = new Kno...
I've perused the MSDN documentation and I couldn't find a statement one way or the other. What I'm interested in is:
Can I call GdiplusStartup() on one thread and then use Gdiplus on another thread? Or do I need to call GdiplusStartup() for each thread?
If I have a Bitmap object on thread 1 and different one on thread 2, can they bot...
Is it safe to call the dispose() method of a JFrame from a different thread (not the EDT)?
...
Does someone know of a good resource for the implementation (meaning source code) of lock-free usual data types. I'm thinking of Lists, Queues and so on?
Locking implementations are extremely easy to find but I can't find examples of lock free algorithms and how to exactly does CAS work and how to use it to implement those structures.
...
I wanted my application to just have one TimeZone object which will be used by many SimpleDateFormat and Calendar objects from the other places concurrently. This is to avoid having to always do TimeZone.getTimeZone(ID).
I know SimpleDateFormat and Calendar classes are not thread safe, which is why I configure one thread to always cr...
It is safe to assume that working with or passing around an immutable object would always be threadsafe?
...
We know from the C# specification that reference read/writes are atomic. In a statement that accesses member of an object, will the reference also be accessed atomically?
I think yes because it is also a kind of implicit reference read which the compiler must provide atomicity for while generating code for it.
In the same statement, ac...
I am running Linux, and I would like to be able to make parallel function calls into a shared library (.so) which is unfortunately not threadsafe (I am guessing it has global datastructures).
For performance reasons, I do not want to simply wrap the function calls in a mutex.
What I would like to do is to spawn, say 4 threads, and also...
Lets say we have this code that runs in the constructor:
Dim initVectorBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(initVector)
Dim saltValueBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(saltValue)
Dim passPharse As String = GenerateKeyString(EncryptionKey)
Dim password As Rfc2898DeriveBytes = New Rfc2...
In my server application (written in C#), I need to create a pool of same type of objects. I pull an object from pool when I need, and it goes back to pool when it is no longer needed. Mechanism needs to be thread safe since different threads will be asking and submitting these objects. I understand that frequently locking something to m...
I am trying to get a string of length 15 to be used as primary key in database tables. The following code in java returns some key with length 35
UUID.randomUUID().toString()
Can I change it to return a key of the length 15 ?
How to ensure thread safety?
Any help is greatly appreciated.
...
I am writing a library. The library can be used by applications that use log4j loggers and java.util.logging loggers.
So, I wrote a quick wrapper class, that encapsulates both loggers. I allow the application to set one or both loggers. And in my library I use the encapsulated class to print to either logger.
My question is, since many...
I am using a simple yet effective anti-spam system at a comments module which seems to be working flawlessly for more than a year now.
Since it is capable of recognizing automated comment spam attempts, I am thinking of extending this security module with an ability of adding the offender IPs to a blacklist automatically.
Do you think ...
I'm trying to use WebClient to download a bunch of files asynchronously. From my understanding, this is possible, but you need to have one WebClient object for each download. So I figured I'd just throw a bunch of them in a queue at the start of my program, then pop them off one at a time and tell them to download a file. When the file i...