The code below is going to be called from a website so having a static dictionary object in a non static class needs to be threadsafe. Basically the purpose of the code is to encapsulate logic and to maintain the life-time of the perfmon counter(s), which are stored in an instance of CounterContainer. The constructor is called passing ...
Hi,
Im having some trouble passing an NSNumber object to different threads.
I call a function on viewDidload that loads up some objects from core data as a background process. which calls another function which loops through the loaded objects to see if there are any images associated with it alredy downloaded. if its not present, downlo...
How do I control when a thread is permitted to access an object and when it is not.
For example, if I have situation like below, I want to make sure that when I am doing something with objFoo in my ButtonClick event, I should not be able to touch objFoo from my doSomethingWithObjFoo method.
private void button1_Click(object sender, Eve...
This is a two part question.
First, let's say that I have a function that is executing in a another thread:
private AutoResetEvent StopEvent = new AutoResetEvent( false);
public void WorkerThread()
{
while( !StopEvent.WaitOne( 10)) {
a();
b();
c();
}
}
Now I want to pause this thread. Thread.Suspend is out of the qu...
If I have a deque or list that's being manipulated on different threads, can I call empty without a lock? The standard doesn't say anything about threads, so I know this won't be portable, but I'm using gcc 4.4. I'm also curious to know if this is safe on other implementations in case I ever decide to, say, switch to the intel compiler...
I'm using vb.net 2005, I've got the following code running a thread to download a file. However, the process fails sometimes when trying to read the local copy of the file. I think I may need to unlock the local file somehow but I'm not sure how to do this. Can someone take a look and advise me ?
Dim BP1Ended As Boolean = False
Private ...
I have a question concerning the use of boost::lock_guard (or similar scoped locks) and using variables that should be protected by the lock in a return statement.
How is the order of destroying local objects and copying the return value? How does return value optimization affect this?
Example:
Data Class::GetData()
{
boost::lock_...
I am trying to Tune a thread which does the following:
A thread pool with just 1 thread [CorePoolSize =0, maxPoolSize = 1]
The Queue used is a ArrayBlockingQueue:
http://download.oracle.com/javase/6/docs/api/java/util/concurrent/BlockingQueue.html#poll%28long,%20java.util.concurrent.TimeUnit%29
Quesize = 20
BackGround:
The thread tr...
Hi
I make a tool and provide an API for external world, but I am not sure whether it is thread safe. Because users may want t use it in multiple-thread environment. Is there any way or tool that I can use to verify whether my API is thread safe in Java?
...
What is the best way to run code on a separate thread? Is it:
[NSThread detachNewThreadSelector: @selector(doStuff) toTarget:self withObject:NULL];
Or:
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
...
Hi All
I have the following code, which runs a WPF window on it's own dedicated UI thread:
// Create the dedicated UI thread for AddEditPair window
Thread addEditPairThread = new Thread(() =>
{
// Initialise the add edit pair window
addEditPair = new AddEditPair(this);
addEditPair.PairRecordAdded += new EventHandler<PairRec...
The msdn documentation states that a static generic Queue is thread-safe. Does this mean that the following code is thread-safe? In other words, is there a problem when a thread Enqueues an int and another thread Dequeues an int at the same time? Do I have to lock the Enqueue and Dequeue operations for thread-safety?
class Test {
pu...
If I browse to an asp.net web page that has the following in the page load, how long will the thread continue to run for after I close the browser? I would assume it would just finish on its own, but I'm not sure if it will terminate when the session ends, or something like that.
protected void Page_Load(object sender, EventArgs e) {
...
Is it safe to use the ARPACK eigensolver from different threads at the same time from a program written in C? Or, if ARPACK itself is not thread-safe, is there an API-compatible thread-safe implementation out there? A quick Google search didn't turn up anything useful, but given the fact that ARPACK is used heavily in large scientific ca...
Hi, i had these questions in my mind since i was reading some new topics on processes and threads. I would be glad if somebody could help me out.
1) What happens if a thread is marked uncancelable, and then the process is killed inside of the critical section?
2) Do we have a main thread for the program that is known to the operating s...
All,
I started learning Java threads in the past few days and have only read about scenarios where even after using synchronizer methods/blocks, the code/class remains vulnerable to concurrency issues. Can anyone please provide a scenario where synchronized blocks/methods fail ? And, what should be the alternative in these cases to ensu...
Hi all!
I have WPF application that performs some calculations in BackgroundWorker. The problem is that when I try to update property (which calls NotifyPropertyChanged in setter) in RunWorkerCompleted event handler I get InvalidOperationException - The calling thread cannot access this object because a different thread owns it.
This M...
Hello All,
I'm running into kindof an annoying problem and would need some advice...
Let's say I have a bunch of small MyObject's, that can construct bigger MyExtendedObject's. MyExtendedObject's are big and CPU consuming so construction is lazy, and I try do remove them from memory as soon as possible:
MyExtendedObject * MyObject::Ge...
Sometimes I see the term "free-threaded" to describe a class or a method. It seems to have a similar or identical meaning to "thread-safe".
Is there a difference between the two terms?
...
I'm working on an RPG for Android, using the LunarLander API demo. I've already made a game using this demo (Porcupine Assassin, check it out!) so I've got a good grasp of the Canvas class and things of that nature.
My problem is, in RPGs you need a way to access inventory, stats, etc. So I've set the BACK button to start the class Inve...