multithreading

using an object from one specific thread

i have a COM object that i am using in dotnet and i have to call it always on the same thread. The issue is that conceptually it is being for multiple things throughout the program. What is the best way for ensuring that all uses of this object on called on this one specific background thread? Example code would be great. ...

How do I use SDl_Threads properly?

I am new to threads,SDL and how graphic work in general. I've been looking through all of LazyFoo's SDL tutorials, and had helped me greatly. But in his tutorials about multi threading, he commented that you should never use video functions in separate threads, or might cause problem. I am curious how it should be done, as I still have a...

Immutability and thread safety in Python

I'm cleaning some of the Python code I wrote when I was...not as knowledgeable. Primarily I am killing some of the complexity that stemmed from an incomplete understanding of threading in Python. I need to make a list of items thread-safe, and I'd like to do it via immutable lists, instead of the usual locking approach. I know that immut...

Should all event-driven frameworks be single-threaded?

http://weblogs.java.net/blog/kgh/archive/2004/10/multithreaded_t.html argues that multithreaded GUI frameworks are a failed dream. What about non-GUI frameworks? Does this rule of thumb extend to all event-driven frameworks? Here is a quote from the article that caught my attention: The problem of input event processing is that...

Are inline functions in C/C++ a way to make them thread-safe?

I make the following reasoning, please tell me what's wrong (or right) about it: "If inlining a function duplicates the code in the place the function is called, then the static and local variables are duplicated for each function calling it and if there is only one thread running the function that calls the inlined one at the same time...

To multiple thread or not

I'm creating a windows console application that will read text file line by line and extract the data from the string that is fixed length data. The application is written as windows application for now but will convert to windows console app later on. I've notice that it take a while for the application to run from reading the text, ins...

What is the difference between Server side skills and desktop development skills?

This morning, I read a very good question about what the person should expect from a Sharepoint position. I have a similar question about server side engineering. What can I expect from server side engineering positions, and how is it similar and different from desktop development? I have experience with WinForms, WPF, some light mu...

How to start a UI thread in C#

Hi, I know I can start a new worker thread from with .NET. But how do I start a new UI thread (like in MFC)? I don't mind if the solution is restricted to Windows boxes only; I also would like the solution to be purely .NET - no p/invokes to CreateThread, etc. Any input appreciated. ...

Why cannot I acquire exclusive lock?

The following program prints: Entered 3 Entered 4 Wait for Exited messages Exited 3 Exited 4 Meaning that it cannot acquire an exclusive lock on resource. Why? public class Worker { public void DoIt(object resource) { Monitor.Enter(resource); Console.WriteLine("Entered " + Thread.CurrentThr...

Thread safe usage of System.Configuration

Is there an easy method of accessing custom System.Configuration-based configuration data through a thread-safe interface without requiring each execution context from loading/reloading configuration information which would be computationally burdensome? System.Configuration classes, like most (all?) other classes in Microsoft's .Net li...

How to properly call SQLite functions from background thread on iPhone?

I'm using an SQLite database in my iPhone app. At startup, there are some database actions that I want to perform in a separate thread. (I'm doing this mainly to minimize startup time.) Occasionally/randomly, when these database calls are made from the background thread, the app will crash with these errors: 2009-04-13 17:36:09.932 Act...

BackgroundWorker and Threads

What are the pros and cons in using the either for achieving a given task. The million dollar question is which one to use and when? Many Thanks. ...

Asynchronous Vs. Synchronous Execution, What does it really mean?

Asynchronous Vs. Synchronous Execution, What does it really mean? ...

Is the normal union/find algorithm thread safe without any extra work?

The standard union/find or Disjoint-set data structure has very good running times (effectively O(1)) for single threaded cases. However what is it's validity/performance under multi-threaded cases? I think that it is totally valid even without locking or any atomic operations aside from atomic pointer sized writes. Does anyone see any ...

Get ThreadName from ThreadID

Is there a way to get a Thread's ThreadName from a ThreadId? (from say, a ThreadID like 10, or 15, etc.) ...

Anyway to detect if a threaded method has completed.

Hi, I've got a queue, which is basically the producer/consumer queue in the albahari.com threading book, which takes an queue item off the queue, which is an action execution block off the queue and then calls a method to execute the actionlist within the queue item. I can kill the queue easily enough by enqueing a null actionblock an...

How to detect a hung thread?

Hi, Is it possible to detect a hung thread? This thread is not part of any thread pool, its just a system thread. Since thread is hung, it may not process any events. Thanks, ...

Trying to wrap my wee brain around how threads deadlock...

First, here's a sample: public class Deadlock { static class Friend { private final String name; public Friend(String name) { this.name = name; } public String getName() { return this.name; } public synchronized void bow(Friend bower) { System.out.fo...

Understanding Goetz's article on Thread safety of HttpSession

Referring to Goetz's article, I want to refer to this piece of code HttpSession session = request.getSession(true); ShoppingCart cart = (ShoppingCart)session.getAttribute("shoppingCart"); if (cart == null) { cart = new ShoppingCart(...); session.setAttribute("shoppingCart", cart); } doSomethingWith(cart); From my avail...

Requested ThreadPool is inactive

While running the batch process in .net Application I am gettting this error "Requested ThreadPool is inactive". I dont know how to resolve. Please help out ...