22
votes
5answers
3k views

Is this (Lock-Free) Queue Implementation Thread-Safe?

I was trying to create a lock-free queue implementation in Java, mainly for personal learning. The queue should be a general one, allowing any number of readers and/or writers concurrently. Would you ...
5
votes
2answers
235 views

How can I make this fast and more readable?

I made a simple library to help me doing A/B tests in a web app. The idea is simple: I have two or more page options (url) for a given page and every call to the library method should give me a url so ...
4
votes
2answers
176 views

Multithreading correctly done?

I rarely write multithreaded code, and am on shaky ground when doing so. I make mistakes. I would like a sanity check of something I am going to introduce in one of my apps. There will be exactly ...
4
votes
6answers
383 views

Strategy for avoiding threadpool starvation while performing cpu bound jobs in a queued fashion

My aim is to avoid using threadpool threads for CPU bound work, thus avoiding a situation where IIS stops responding to new requests. Can you see any problems with the code below? Is this a ...
4
votes
1answer
179 views

Is this custom dictionary thread-safe?

I'm writing a custom dictionary which is to be used as a helper for caching. The reason I use delegates is because it must interface with generated code, so I can't change this. However, you can ...
4
votes
2answers
1k views

Did I need to use lock to ensure that Queue.Dequeue is Thread Safe in this case on .NET 2.0?

Is this ok? I am using C# and .NET 2.0 I have this Queue declared in my class : static private Queue<SignerDocument> QUEUE = new Queue<SignerDocument>(); I fill this Queue with some ...
4
votes
1answer
287 views

Can you spot a threading bug in this implementation of costreams?

I am not very good with thread-safety and often fall prey to subtle issues in concurrency. Therefore, I hope that someone here might be able to tell me whether there is a subtle concurrency issue ...
4
votes
1answer
269 views

Activeresource-response gem

I created my first gem for Rails today. https://github.com/Fivell/activeresource-response. This gem adds possibility to access http response object from result of activeresource call. I don't know ...
4
votes
1answer
295 views

is this thread safe?

I am using this code for receiving log messages from my clients I receive more than 1000 connections per minute. I want to increase my log handling. I did with java threading. I have a doubt if it ...
4
votes
2answers
869 views

thread-safe stl map accessor

So after learning that stl map containers are not inherently atomic and therefore not thread-safe (check out this related stackoverflow question and usage example), I decided to create code that would ...
4
votes
1answer
998 views

Singleton class extending a parent class to utilise shared functionality

I have a singleton class which extends from an abstract java class. Two singleton classes extend from ItemImageThreadManager, the reason for this is to use shared scheduling functionality. A thread is ...
3
votes
1answer
187 views

Java thread safety and caching techniques

This is my first Java multi-threading code. It is part of an Android application that is a client to a webpage that serves books. Each page of the book is in a separate PDF, and the Book class ...
3
votes
2answers
54 views

Is this a scenario to use volatile instead of synchronized?

I want to know if using volatile in this scenario will give a better performance than using synchronization. Specifically for the paused and running instance variable in the SimulationManager class. ...
3
votes
1answer
312 views

.Net caching service - thread safety

I have a simple cache service that i am using inside my WPF prism application, i am concerned about the thread safety of it - we will be accessing this via multiple threads and using the current code ...
3
votes
1answer
100 views

Thread Safety issues in the multithreading code

I am working on a project in which I have two tables in a different database with different schemas. So that means I have two different connection parameters for those two tables to connect using ...

1 2 3
15 30 50 per page