multithreading

What is the best way to defer code execution?

I have many methods calling each other that each have to certain tasks, some of them asynchronous, that all operate on a DOM (so only one thread must access the DOM at any time). For example: object A() { /*...A() code 1...*/ var res = B(); /*...A() code 2 that uses res...*/ } object B() { /*...B code 1...*/ var re...

boost or openMP for multithreading?

Hi, i have to parallize some code and a fried of mine suggested using boost for it. Right now i have a look into openMP and i am wondering what you think is better for that task. ...

How can I handle scheduling threads with dependencies in Perl?

I have the following scenario: sub_1 can run immediately sub_2 can run immediately sub_3 can run only after sub_1 finishes sub_4 can run only after sub_1 finishes sub_5 can run only after sub_2 finishes sub_6 can run only after sub_2 finishes sub_7 can run only after both sub_1 and sub_2 finish sub_8 can run only after both sub_1 and su...

Update datagridview row from a thread in c#

I have a datagridview on a windows form application. Application post all displayed data to an external website. website return codes so application detrmine status of posted data. I need to create a parametrized thread that take row index as parameter and post the row data and update it by return value. (It may involve changing row b...

Background worker synchronization

Lets say I have a class that is supposed to generate some ID (for example GUID) for me. Now unfortunately the ID generation is a somewhat long process and if I need a hundred of those I run into a problem of significant slowdowns. In order to avoid those, I keep a queue of pre-generated ID, and when this queue starts to run down on them ...

c# threading behaviour

Can anyone explain why this works: Object ready_lock = new Object(); Object thread_lock = new Object(); public static bool able_to_get_lock = false; public void GetThreadLock() { if (Monitor.TryEnter(thread_lock,2)) { able_to_get_lock = true; } } [TestMethod] public v...

java atomics operations

Is correct to divide the following statements: int v = ++j; as: read j value (atomic); increment by 1 the value read (NON atomic possibly interference by other thread); write the adding result to i (atomic); write i into v (atomic) ...

JVM consumes all CPU, most threads as BLOCKED. JVM bug?

Last night, a server (JBoss 5.1GA, Java(TM) SE Runtime Environment (build 1.6.0_20-b02), Java HotSpot(TM) 64-Bit Server VM, running in a Linux VM on VMWare) suddenly started to use 100% CPU. The app is a fairly typical J2EE business app running Seam, nothing particular about it. The load was extremely low at that time. I managed to get...

Simple Thread Sample Delphi

Hi, I am new with this stuff of Threading in Delphi. so, I am trying to make a simple query aplication that make a bit call up for the database and take a bit of time, so I want to alert the user that there is a background process and have to be patient. I tried many samples, but none of them work for me, Please, could somebody show me ...

How to prioritise specific threads in tomcat

I am working on a Java web application for tomcat6 that offers suggest functionality. This means a user types in a free text and get suggestions for completing his input. It is essential that the web application needs to react very fast to make sense. This web application makes suggestions for data that can be modified at any time. If n...

Delphi and CreateThread()

I am calling CreateThread from a delphi application and it seems to work, however I get a system error: code 1400, invalid window handle. the code is as follow: procedure TForm1.SyncFile; var thr: THandle; thrID: DWORD; begin thr := CreateThread(nil, 0, @sync, nil, 0, thrID); if (thr = 0) then ShowMessage('Error creating th...

Unlocked, shared hash operation safety in threaded perl

Question Is it safe for multiple threads to fetch and store simple, individual values in a shared hash without lock()ing the hash? Can you prove it or cite strong authority? Background My belief was that at worst unlocked hash manipulations could lead to segfaults. However, I've very recently seen code that coordinates worker thread...

Increasing the Concurrent Requests on a .NET Remoting app under IIS

We have a .NET 2.0 Remoting server running in Single-Call mode under IIS7. It has two APIs, say: DoLongRunningCalculation() - has a lot of database requests and can take a long time to execute. HelloWorld() - just returns "Hello World". We tried to stress test the remoting server (on a Windows 7 machine) in a worst case scenario by b...

When I serve an ASP.NET page, can I render the various controls on the page in parallel?

When I serve an ASP.NET page, can I render the various controls on the page in parallel? I have a few Telerik controls (RadGrids) on the page and when I step through the page being loaded, it seems as though the controls are databound and rendered serially. Maybe this behavior is because I am hooked in with the debugger. Is there anyw...

C# .NET events and multithreading

Hello, I am developing an application that is split into multiple .NET assemblies (one main executable and a set of class libraries). Currently, I am using a WPF GUI, but I need to maintain the flexibility to possibly switch to another GUI framework at a later time. Here is my problem: one of the class libraries performs some work on a...

Why would a threading-related exception only happening outside of the Visual Studio IDE/debugger?

I'm using a BackgroundWorker to do some work. Part of that work involves showing a form. That form has some controls that are set as drag & drop targets. I know that the BackgroundWorker uses the ThreadPool to run, and that threads from the thread pool use the MTA threading model. I also know (thanks to this question) that when you have...

How to load complex views concurrently

I have an Android activity that creates custom views, and it is an expensive process. I tried to use a Handler, but when I do, the progress dialog that shows, spins like once every 5 seconds. So I tried to use an AsyncTask. Now the progressDialog spins, but then it crashes, because it isn't allowed to load the UI? How can I do this witho...

Spawning a thread within web-request handler (.NET + IIS7)

When user clicks "Update" button on the page, it send a GET request. Within GET request handler I need to update database using data from other web sites (I download XML chunks that I use to update database). I use thread pool to fork the process. It works well on local box. On the server (shared hosting with DiscountAsp.net) though it o...

Threading: Locking Under the hood of

What happens when we use the lock object? I am aware that it the runtime makes use of the monitor.Enter and Exit methods. But what really happens under the hood? Why only reference types to be used for locking? Even though the object used for accomplishing the locking is changed, how come it still provides thread safety? In the curren...

Join threads from thread pool.

I have 30+ tasks that can be executed in parallel. I use ThreadPool for each task. But parent-function should not return until all tasks has completed. I need a thread sync handle that would release WaitOne when its count reaches 0. Something like: foo.StartWith(myTasks.Count); foreach (var task in myTasks) { ThreadPool.QueueUserWo...