Tagged Questions

programming concept applicable in the context of multi-threaded programs. A piece of code is thread-safe if it only manipulates shared data structures in a thread-safe manner, which enables safe execution by multiple threads at the same time. (Wikipedia)

learn more… | top users | synonyms

3
votes
2answers
93 views

How is this ThreadSafe?

Given the class Sequence: //This method getNext must return a unique value nextValue public class Sequence { @GuardedBy("this") private int nextValue; public synchronized int getNext() { ...
5
votes
2answers
182 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 ...
3
votes
1answer
56 views

C# Array Mutator Methods to mimic JavaScript Array Mutator Methods

Between .NET's built-in collection libraries and LINQ extension methods, I never have to use arrays. An unfortunate consequence of this is that I am probably less competent in working with this very ...
3
votes
1answer
92 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 ...
4
votes
2answers
128 views

thread-safe lock-free counter

I was using such code: class Counter { private int i = 0; public int Next() { lock (this) { return i++; } } public void Reset() { ...
2
votes
1answer
182 views

Mutex implementation for uniprocessor bare metal embedded OS

I wrote this recently for one of my projects, any error you guys can spot or a feature which could be implemented without eating up resources or some optimisations ? Oh and it isn't meant for Multi ...
2
votes
0answers
186 views

The correct (and safe) way to use a Timer to poll a Delegate

This is a followup to Polling loop to run in a background thread where I was initially using a single thread and Thread.Sleep() to poll a delegate. I was recommended to use a timer and the ThreadPool ...
0
votes
1answer
64 views

Thread Safe Server Querier

I wanted to make a class that connects to my server and returns a value, a url in this case. As Android 4.0 doesn't let me run network task on the main UI thread(rightly so) I have made this. Please ...
1
vote
1answer
94 views

Loading an Object from File with Type-Safety and Thread-Safe access

I'm attempting to write a bit of code that allows for easy and safe access to objects in a file. It seems to work great but I was curious if there was an easier way to do this or if Java already has ...
1
vote
1answer
255 views

Simple generic multithreaded queue

This is a simple thread safe queue that is used in a producer-consumer model. public class ThreadedQueue<TType> { private Queue<TType> _queue; private object _queueLock; ...
4
votes
1answer
213 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 ...
1
vote
4answers
238 views

Thread-safe object cache, for read, high performance in .NET

I want to realize an object cache which holds objects loaded from database, file or other slow access source, to make them available quickly with high performance. There will be a lot of accesses to ...
1
vote
1answer
219 views

Thread safe cache implementation

Please review this implementation of thread-safe chache. public class StaticCacheImpl<T extends Entity> implements StaticCache<T> { private boolean set = false; private ...
0
votes
1answer
955 views

Generic wrapper for System.Runtime.Caching.MemoryCache

I have implemented a simple generic wrapper for MemoryCache class. Its interface looks like ConcurrentDictionary class but I tried to keep it simple. I tried to keep operations atomic, hoping not to ...
2
votes
2answers
179 views

Is this method thread safe?

Are these methods getNewId() & fetchIdsInReserve() thread safe ? public final class IdManager { private static final int NO_OF_USERIDS_TO_KEEP_IN_RESERVE = 200; private static final ...

1 2 3
15 30 50 per page