multithreading

How easy do you find it to write multi threaded code?

I know a lot of developers that struggle to fluently write multi threaded code. They have to spend a lot of time just thinking about the parallelism and what not. It really racks their brains. And even then they don't usually choose the correct lock for the given situation. I.e. a simple Monitor instead of a Reader-Writer... Is it just ...

Stackless python and multicores?

So, I'm toying around with Stackless Python and a question popped up in my head, maybe this is "assumed" or "common" knowledge, but I couldn't find it actually written anywhere on the stackless site. Does Stackless Python take advantage of multicore CPUs? In normal Python you have the GIL being constantly present and to make (true) use ...

Do I need to lock "read only" services when using threading?

I have a service that I am rewriting to use threading. I understand that state from one thread should not be accessed by another, but I'm a little confused by what constitutes 'state'. Does that mean any field/property/method outside of the method scope? Specifically, my service looks something like this: public class MyService { ...

How can threads be avoided?

I've read a lot recently about how writing multi-threaded apps is a huge pain in the neck, and have learned enough about the topic to understand, at least at some level, why it is so. I've read that using functional programming techniques can help alleviate some of this pain, but I've never seen a simple example of functional code tha...

IIS hang state

Any suggestion to detect flaws in VB6 components running under IIS. IIS becomes unstable and after some time enter in a state of hang. The problems occur in the most part only in the production environment. We have many modules running. Probably there are components with bugs and need to identify them. Thanks in advance. ...

To use thread in programming in vb6

I am programming to generate keys in hexadecimal using different random function and write it in the text file. I have only two cmd buttons and status bar which displays the current time and the status of the process. Now on clicking the cmd button for keygeneration the form gets locked up and all the other activity is suspended that is ...

What is the best way to implement a cross-platform, multi-threaded server in C/C++?

Part of the development team I work with has been given the challenge of writing a server for integration with our product. We have some low-level sensor devices that provide a C SDK, and we want to share them over a network for use by people collecting data. Sounds simple, right? Someone would connect a sensor device to their machine in...

Does using ReaderWriterLockSlim cause a memory barrier?

If I am using ReaderWriterLockSlim to acquire read/write locks, do I need to make my variables volatile or use Interlocked.Increment? For example, would the code in the Add method below work fine, or does it need enhancement? public class AppendableList<T> { // semi-immutable; supports appending only private T[] data = new T[16]; ...

How to signal select() to return immediately?

I have a worker thread that is listening to a TCP socket for incoming traffic, and buffering the received data for the main thread to access (let's call this socket A). However, the worker thread also has to do some regular operations (say, once per second), even if there is no data coming in. Therefore, I use select() with a timeout, so...

Limit Access To a Spring MVC Controller -- N sessions at a time

We've licensed a commercial product (product not important in this context), which is limited by the number of concurrent users. Users access this product by going through a Spring Controller. We have N licenses for this product, and if N+1 users access it, they get a nasty error message about needing to buy more licenses. I want to m...

Synchronous work in a BackgroundWorker

My application performs time consuming work independently on several files. I created a BackgroundWorker to pass the work off to on each file, but it appears the backgroundworker is only capable of performing asynchronous work. Is it possible to do several asynchronous tasks in unison with it, or is there a similar object for performin...

Starting and stopping a forked process

Is it possible for a parent process to start and stop a child (forked) process in Unix? I want to implement a task scheduler (see here) which is able to run multiple processes at the same time which I believe requires either separate processes or threads. How can I stop the execution of a child process and resume it after a given amoun...

Displaying splash screen in Delphi when main thread is busy

I'd like to display splash screen while the application is loading. However some 3rd party components block main thread during initilization for several seconds, which causes all forms not to update. Is it possible to have splash screen with own thread so it would update also when main thread is busy? The application is win32 and Delphi...

Improving performance of multithreaded HttpWebRequests in .NET

I am trying to measure the throughput of a webservice. In order to do that, I have written a small tool that continuously sends requests and reads responses from a number of thread. The contents of the inner loop of each thread looks like this: public void PerformRequest() { WebRequest webRequest = WebRequest.Create(_uri); webReq...

How to reduce the memory usage of a WPF app.

I am working on a little bookmark managing app written in C#, using WPF. It just sits in the system tray and is idle 99% of the time. Recently I looked in the task manager and discovered that it uses around 25 megs of memory (and around 12 megs before it is activated for the first time) which I thought was a bit much for an app that does...

How to find what state ManualResetEvent is in?

I am using an instance of ManualResetEvent to control thread access to a resource but I'm running into problems with it. Does anyone know how I can find out during debugging what the state of the object is? That is to say I would like to know if the ManualResetEvent is currently blocking any threads and maybe even how many and which th...

C# Windows Application - Many threads using the same connection?

I've got a c# WINDOWS Application that is multi-threaded. It is my understanding that in a web environment, connections are pooled automatically. It is also my understanding that in a Windows app, this is not the case. Therefore, for a Windows app, the same connection should be used and not closed after each call, but instead closed when...

_nolock CRT functions

I have recently discovered the existence of _nolock functions, and I am surprised by how little info I can find on these. It says it increases performance, but I can't find any benchmark. It also says they can be used in a multi-threaded program if the program does its own locking, but what has to be locked? Should all CRT calls go throu...

Memory allocation and deallocation across threads

I'm still trying to debug a very sneaky memory corruption problem. I came across a section of my code that allocates memory on one thread and deletes it on another. I have a vague feeling that this is wrong, but I'm not sure why. The threads share the process memory and access to these structures is protected by a mutex, so I think ever...

Increase request timeout for a thread in CFML

I have a web application that is generating hundreds of PDFs in batch, using ColdFusion 8 on a Windows/IIS server. The process runs fine on my development and staging servers, but of course the client is cheap and is only paying for shared hosting, which isn't as fast as my dev/staging boxes. As a result, PDF generation threads are timi...