multithreading

Lock free multiple readers single writer

I have got an in memory data structure that is read by multiple threads and written by only one thread. Currently I am using a critical section to make this access threadsafe. Unfortunately this has the effect of blocking readers even though only another reader is accessing it. There are two options to remedy this: use TMultiReadExclu...

Asynchronous processing or message queues in PHP (CakePHP)

Hi all, I am building a website in CakePHP that processes files uploaded though an XML-RPC API and though a web frontend. Files need to be scanned by ClamAV, thumbnails need to be generated, etcetera. All resource intensive work that takes some time for which the user should not have to wait. So, I am looking into asynchronous processin...

Cancelling a long running regex match?

Say I'm running a service where users can submit a regex to search through lots of data. If the user submits a regex that is very slow (ie. takes minutes for Matcher.find() to return), I want a way to cancel that match. The only way I can think of doing this is to have another thread monitor how long a match is taking and use Thread.stop...

how do I repaint an applet while moving a sprite?

I have a little java applet where I create 2 threads, one thread repaints and the other moves an image from a point to where the user clicks. The problem is that when I call the move function it loops until the image is where the user clicks but it wont repaint until I break out of the loop even though the thread doing the moving and the...

Problem only in Vista (.net): call unmanaged dll(Shell32.dll, function: SHEmptyRecycleBin) from thread

***Platform: in Vista(ultimate or home/premium) it does not work, other OS(xp, windows7) it works****** I'm emptying recycle bin using c++.net(or c#.net) inside a thread. When i do this straight (without thread) it works. But if thread used it doesn't. Please watch the code snippet below: namespace EmptyRecycleBin_C{ enum RecycleFlags ...

Make it pretty: processing an array concurrently

I want to convert this linear loop into a concurrent one: for(Item item : ItemList) { processItem(item); } Is this really the shortest way to do this? class Worker implements Runnable { Item item; Worker(Item item) { this.item = item; } public void Run() { processItem(item); } } ExecutorServic...

How to know if code is running on the ui thread or a working thread (MFC Visual C++)

I have a function that is being called from different threads in the application. I need to know whether the thread that executes the code is the main thread(ui thread) or a working thread. Any suggestion? Thanks. ...

Linux/C++ How to debug release application

Hello, I have linux c++ multithreaded application. Now it's tested on production servers and have segfault. Problem is that I cannot reproduce that error on any of my test servers and have no access to production servers. I have no dump or any other useful information. Only line: segfault at 0000000046bf0fb8 rip 000000000048ac6b rsp 0000...

Advantage of setting threads to work on a particular core?

Hi, Is there any evidence to suggest that by manually picking which processor to run a thread on you can improve system performance? For example say you dedicated the thread that does the most work to one core and all other "helper" threads to a second. ...

Blocking functions using OpenMP

I have a GUI application, which listens to a network port from a second thread. I was looking at OpenMP and I was wondering if there are easy ways to create threads like this. I was searching for documentation, but the OpenMP site is not very convenient to navigate. Could someone help? ...

Is there a way to multithread a SqlDataReader?

I have a Sql Query which returns me over half million rows to process... The process doesn't take really long, but I would like to speed it up a little bit with some multiprocessing. Considering the code below, is it possible to multithread something like that easily? using (SqlDataReader reader = command.ExecuteReader()) { while (r...

database locking problems with django

I have a webpage which interacts with several external APIs and in order to speed things up (the speed increase is almost linear because the majority of the time is spent waiting for http responses, etc), the code is threaded so that it pulls the content from several APIs at once. The problem is, I am running into database locking presu...

What is a CPU thread and how is it related to logical threads in code?

I have been seeing in the literature for some of the newer CPU's such as the Intel Xeon "Nehalem-EX" as having 8 cores and 16 threads. What are they talking about here? I saw mention of this in reference so SPARCS too, surely this isn't the kind of logical threads spawned by code ? Is this hyperthreading re-named? ...

master / worker threads and signal handling

I am writing a program, with a master thread and some worker threads, and I would like to get the signal handling right. My problem is the following : Master thread starts and do all allocation Master thread sets a SIGINT signal handler Master threads start worker threads. worker threads don't need special cleanup, however they can b...

Waiting on multiple events C++

Is there a recommended way to wait on multiple inputs. For example I would like my program to be able to receive input from 3 sources: Listen on a thread condition e.g. pthread_cond_wait() Take data from Standard input e.g. getline() Listen on a socket e.g. accept() What is the best way to accomplish this? Do I need a thread for each...

Monitoring many web pages/rss feeds

Hi I would like to monitor many web pages/ rss feeds at the same time and poll them at a regular frequency ( they may all have different update frequencies ). I am thinking about creating a thread for each source I want to mirror that will loop infinitely and then sleep till next update after dealing with the fetched data . Does som...

Generic .Net Producer/Consumer

I'm toying with the idea of implementing a generic Producer/Consumer pair + processing queue in C# for fun. The idea is you can just create objects that implement appropriate IProducer and IConsumer interfaces (default implementations supplied), which will consist mainly of delegates, pass them to a QueueProcessor class instance, tell i...

Where can I find some good examples to learn the basics of threading?

I am at the end of my first year doing computer science and want to mess around with something basic. I want to use threads so I can learn. What are some good examples to learn from? ...

GDI+: how do you render a Graphics object to a bitmap on a background thread?

I'd like to use GDI+ to render an image on a background thread. I found this example on how to rotate an image using GDI+, which is the operation I'd like to do. private void RotationMenu_Click(object sender, System.EventArgs e) { Graphics g = this.CreateGraphics(); g.Clear(this.BackColor); Bitmap curBitmap = new Bitmap(@"ro...

Implement thread-safe collection for data-binding in .NET

I have a Windows Forms application that displays a form with a DataGridView bound to a custom collection that inherits BindingList. I'm using the BindingSource / DataSource mechanism for data-binding. The form is a monitor that displays status information contained in the collection. Each element of the collection represents status in...