multithreading

Is putting thread on hold optimal?

Application has an auxiliary thread. This thread is not meant to run all the time, but main process can call it very often. So, my question is, what is more optimal in terms of CPU performance: suspend thread when it is not being used or keep it alive and use WaitForSingleObject function in order to wait for a signal from main process? ...

What makes a pthread defunct ?

i'm working with a multi-threaded program (using pthreads) that currently create a background thread (PTHREAD_DETACHED) and then invokes pthread_exit(0). My problem is that the process is then listed as "defunct" and curiously do not seems to "really exists" in /proc (which defeats my debugging strategies) I would like the following req...

Deterministic dispose of ThreadStatic objects

The ThreadStatic attribute declares a static variable as unique-per-thread. Do you know an easy pattern to correctly dispose such variables? What we used before ThreadStatic is a ThreadContextManager. Every thread was allocated a ThreadContext which retained all thread-specific information. We spawned some threads and let them work. The...

Threading when sending emails

Hi, I have a simple function that sends out emails, how would I go about using threads to speed email delivery? Sample code would be ideal. ...

Is reading /dev/urandom thread-safe ?

This is the code: unsigned int number; FILE* urandom = fopen("/dev/urandom", "r"); if (urandom) { size_t bytes_read = fread(&number, 1, sizeof(number), urandom); DCHECK(bytes_read == sizeof(number)); fclose(urandom); } else { NOTREACHED(); } If not, how do I make it thread-safe? ...

Problem with synchronizing on String objects?

I have a webapp that I am in the middle of doing some load/performance testing on, particularily on a feature where we expect a few hundred users to be accessing the same page and hitting refresh about every 10 seconds on this page. One area of improvement that we found we could make with this function was to cache the responses from the...

Which programming language makes concurrent programming as easy as possible?

If you want to create programs with threads/processes that run parallel you have to learn about many stuff, like race conditions, locks, semaphors, monitors, deadlocks .... Is there a language that makes creation of parallel programs as easy as object-oriented programming languages help creating complex architectures? Or which programmi...

Will pthread_detach manage my memory for me?

Suppose I have the following code: while(TRUE) { pthread_t *thread = (pthread_t *) malloc(sizeof(pthread_t)); pthread_create(thread, NULL, someFunction, someArgument); pthread_detach(*thread); sleep(10); } Will the detached thread free the memory allocated by malloc, or is that something I now have to do? ...

What's the best way to read and parse a large text file over the network?

I have a problem which requires me to parse several log files from a remote machine. There are a few complications: 1) The file may be in use 2) The files can be quite large (100mb+) 3) Each entry may be multi-line To solve the in-use issue, I need to copy it first. I'm currently copying it directly from the remote machine to the local ...

What's the difference between a worker thread and an I/O thread?

Looking at the processmodel element in the Web.Config there are two attributes. maxWorkerThreads="25" maxIoThreads="25" What is the difference between worker threads and I/O threads? ...

How is a real-world simulation designed?

I am fascinated by the performance of applications such as "Rollercoaster Tycoon" and "The Sims" and FPS games. I would like to know more about the basic application architecture. (Not so concerned with the UI - I assume MVC/MVP piriciples apply here. Nor am I concerned with the math and physics at this point.) My main question deals ...

How does cherrypy handle user threads?

I'm working on a django app right and I'm using cherrypy as the server. Cherrypy creates a new thread for every page view. I'd like to be able to access all of these threads (threads responsible for talking to django) from within any of them. More specifically I'd like to be able to access the thread_data for each of these threads from w...

Detecting file being reopened in Java

I'm working on a small Java application (Java 1.6, Solaris) that will use multiple background threads to monitor a series of text files for output lines that match a particular regex pattern and then make use of those lines. I have one thread per file; they write the lines of interest into a queue and another background thread simply mon...

Is there a way to have managed processes in Perl (i.e. a threads replacement that actually works)?

I have a multithreded application in perl for which I have to rely on several non-thread safe modules, so I have been using fork()ed processes with kill() signals as a message passing interface. The problem is that the signal handlers are a bit erratic (to say the least) and often end up with processes that get killed in inapropriate st...

Setting the thread /proc/PID/cmdline ?

On Linux/NPTL, threads are created as some kind of process. I can see some of my process have a weird cmdline: cat /proc/5590/cmdline hald-addon-storage: polling /dev/scd0 (every 2 sec) Do you have an idea how I could do that for each thread of my process? That would be very helpful for debugging. /me now investigating in HAL sourc...

What high level languages support multithreading?

I'm wondering which languages support (or don't support) native multithreading, and perhaps get some details about the implementation. Hopefully we can produce a complete overview of this specific functionality. ...

Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on.

I have a scenario. (Windows Forms, C#, .NET) There is a main form which hosts some user control. The user control does some heavy data operation, such that if I directly call the Usercontrol_Load method the UI become nonresponsive for the duration for load method execution. To overcome this I load data on different thread (trying to ch...

Network Multithreading

I'm programming an online game for two reasons, one to familiarize myself with server/client requests in a realtime environment (as opposed to something like a typical web browser, which is not realtime) and to actually get my hands wet in that area, so I can proceed to actually properly design one. Anywho, I'm doing this in C++, and I'...

Is there a way to indefinitely pause a thread?

I've been working on a web crawling .NET app in my free time, and one of the features of this app that I wanted to included was a pause button to pause a specific thread. I'm relatively new to multi-threading and I haven't been able to figure out a way to pause a thread indefinitely that is currently supported. I can't remember the exac...

Splitting log4j Output with Quartz Worker Threads

I'm working on an application that consists of an overall Quartz-based scheduler and "CycledJob" run using CronTriggers. The purpose of the application is to process inputs from different email inboxes based on the source country. Based on the country that it comes in from (i.e. US, UK, FR, etc.) the application triggers one job thread...