multithreading

Would twisted be a good choice for building a multi-threaded server?

I need to pull from hundreds of pop3 email accounts, and i want to build a robust server to do this. Would twisted be a good choice for this type of project? Right now a simple prototype would be to pull from a single pop3 account, then it would pull from many but it would be a serialized process. I want to create a server that has mu...

.NET Async TcpListener / TcpClient Question...

I'm at a bit of a loss as to how to properly implement the asynchronous methods for TcpListner and TcpClient int .NET. I've read over quite a few posts on hear and I believe I have the code to accept new clients on the server taken care of. Here is the code for acception new connections: Public Sub Start() m_oListener = New TcpLis...

getting inconsistent/wrong output in the program Multi -Threading java

/* This should always produce 0 as output since all three methods increment(), decrement(), value() are thread safe(synchronized). but it is returning 1 */ class Counter implements Runnable { private int c = 0; public synchronized void increment() { c++; } public synchronized void decrement() { c--; ...

Load an OpenGl view in the background. iPhone

I have an OpenGL view that renders a 3D model. It is a basic modification on Apples EAGLView. This view is added to a controller's .view and displayed with presentModalViewController: . I would like to do all of the model loading, and OpenGL state configuration in a background thread at app launch before the user chooses to display the v...

WinDbg to debug System.IO.IOException

I have a full dump file from a custom exe crash. When i review the threads, i see System.IO.IOException and print exception gives me the below error. I suspect there is some sort of thread racing leading to this since we are on a vanilla Windows2008 (x64) server that doesn't have any virus scanners or indexing services installed. Any ide...

Question about terminating a thread cleanly in .NET

I understand Thread.Abort() is evil from the multitude of articles I've read on the topic, so I'm currently in the process of ripping out to of my abort's in order to replace it for a cleaner way; and after comparing user strategies from people here on stackoverflow and then after reading "How to: Create and Terminate Threads (C# Program...

Memory Consistency Errors vs Thread interference

What is the difference between memory consistency errors and thread interference? How does the use of synchronization to avoid them differ or not? Please illustrate with an example. I couldn't get this from the sun Java tutorial. Any recommendation of reading material(s) to understand this purely in context of java would be helpful. ...

Delphi 2010: No thread vs threads

Hello everyone, I'm user of delphi 2010, my current machine is intel core i7, running windows 7 x64. I've write the following codes: type TForm1 = class(TForm) Memo1: TMemo; Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private FCount: ...

pthread sleep linux

I am creating multiple threads programme using pthread. Is sleep() cause the process ( all the threads) to stop executing or just the thread where I am calling sleep? Thanks ...

Efficient structure for Multiple Thread access

I need to implement a mechanism which has a datastruture (Queue at this moment) that contains a list of pending request objects which are marked by different threads when being used and taken off when a thread is finished using it. This datastructure could have up to a few thousand items in it at any given time and N threads will be t...

Is this a good impl for a Producer/Consumer unique keyed buffer?

Can anyone see any problems with this Producer/Consumer unique keyed buffer impl? The idea is if you add items for processing with the same key only the lastest value will be processed and the old/existing value will be thrown away. public sealed class PCKeyedBuffer<K,V> { private readonly object _locker = new object(); private...

boost::threads execution ordering

hello i have a problem with the order of execution of the threads created consecutively. here is the code. #include <iostream> #include <Windows.h> #include <boost/thread.hpp> using namespace std; boost::mutex mutexA; boost::mutex mutexB; boost::mutex mutexC; boost::mutex mutexD; void SomeWork(char letter, int index) { boost:...

Handle Exceptions from Thread in Global Exception Handler?

Hi, I have a main application with a global exception handler installed. Now, for some specific exceptions being raised within another thread I want the global exception handler to be invoked. But it does only handle exceptions from the main thread. I also tried the following from within the thread but it does not work either: RunInMai...

Basic Threading Question

This question has probably been asked in various ways before, but here is what I want to do. I am going to have a Windows form with many tabs. Each tab will contain a grid object. For each tab/grid that is created by the user, I would like a spawn off a dedicated thread to populate the contents of that grid with constantly arriving infor...

Can't find a modern Implementation of Object Pool in Java

I'm looking for a modern implementation of an object pool in Java. I can see the apache commons one, but to be honest, I'd rather one that uses generics, and the concurrency stuff from more recent versions of java. Does the commons pool really work well? The code looks pretty, erm, ugly. I'd need something that allows custom liveness v...

using volatile on atomic variables

Using volatile on a variable reduces the risk of memory consistency error (Please correct me if this reveals some holes in my understanding of any relevant concept). So in the following example even though the variable c1 is volatile, still the occurrence of memory constancy error results in c1 becoming 15 or sometimes 14 in the output ...

Should I be using Application.Lock()?

Consider the following situation: I'm using the Application object in ASP.NET to store a collection(List(of MyObject)) that is being accessed concurrently by several users. While I understand that reading from the Application object is thread safe, I'm wonder how I should make this code thread safe: objList = Application("GlobalList")...

Where is the event dispatch thread called?

I read that all the code which constructs Swing components and handles Events must be run by the Event Dispatch Thread. I understand how this is accomplished by using the SwingUtilities.invokeLater() method. Consider the following code where the GUI initialization is done in the main method itself public class GridBagLayoutTester ...

How to debug this error when none of my code shows up in the stack ?

I'm sometimes getting the following error in my application: Cannot use a DependencyObject that belongs to a different thread than its parent Freezable I know how to solve this kind of error, but in that case I have no idea where it is happening, so I don't know what to fix... The exception's stack trace only contains .NET framewor...

Win API Interlocked operations for 32-bit int type

If we have: __int32 some_var = 0; What is the best (if any) way to call InterlockedExchange, InterlockedIncrement and other interlocked functions which require LONG* for some_var ? Since, there is guarantee that LONG is 32 bit on any Windows, it's probably safe just to pass (long*) some_var. However, it seems to me quite ugly and I c...