multithreading

pthread_join - multiple threads waiting

Hi, Using POSIX threads & C++, I have an "Insert operation" which can only be done safely one at a time. If I have multiple threads waiting to insert using pthread_join then spawning a new thread when it finishes. Will they all receive the "thread complete" signal at once and spawn multiple inserts or is it safe to assume that the thr...

Should you lock resources when reading values?

When doing thread synchronization in C# should I also lock an object when I read a value or just changing it? for example I have Queue<T> object. Should I just lock it when doing the Enqueue and Dequeue or should I also lock it when checking values like Count? ...

QNX c++ thread question

Hello, I have a question concerning this code which I want to run on QNX: class ConcreteThread : public Thread { public: ConcreteThread(int test) { testNumber = test; } void *start_routine() { for(int i = 0; i < 10; i++) { sleep(1); cout << testNumber << endl; } } private: ...

Converting to Multi-Threaded Socket Application

As I am currently doing this project in only C, I've up untill this point only used my webserver as a single threaded application. However, I dont want that anymore! So I have the following code that handles my Work. void BeginListen() { CreateSocket(); BindSocket(); ListenOnSocket(); while ( 1 ) ...

mysql select - how to retrieve a result for threaded/nested messages?

I'm creating a threaded message board and I'm trying to keep it simple. There's a message table, and then a replies table that has an 'reply_id' field that can be null to indicate a top level response, or a value that indicates a threaded response. I'm a bit confused on how to do a SELECT call on this type of table though? Reply -id...

POSIX cancellation points

Can anyone point me towards a definitive list of POSIX cancellation points? I was just about to answer a question on stackoverflow and realised I didn't know my stuff well enough! In particular, are accept() and select() cancellation points? I have an old book that says no, but I've seen sites on the internet claim that they are. Con...

How to enable native threads support in Bigloo Scheme in OS X?

I am trying to compile Bigloo Scheme from source and I cannot figure out how to enable native thread support via ./configure in OS X 10.5 (Leopard) (and I haven't read anywhere that threading is not supposed to work on this platform). I run ./configure --enable-sqlite --enable-web --enable-ssl --enable-pthreads --enable-fthreads, but th...

Duplex Callbacks or Client-Side Threading for Responsive WCF Clients

I have a certain service where specific functions will take longer to call than others, sometimes they might take seconds to return. In order to prevent the client's UI being blocked when this happens what is the preferred solution: Use a Duplex channel and simply use the callbacks to update the UI when data is received. Use a separate...

Thread stops doing its job

We have a C# application that connects to a FTP server, downloads some files, disconnects, and after a certain amount of time (selected by the user through the UI) reconnects and repeats the process. We implemented this using BackgroundWorker, but we noticed that after running for a longer time, the program stopped logging its actions, b...

Is a string property itself threadsafe?

String's in C# are immutable and threadsafe. But what when you have a public getter property? Like this: public String SampleProperty{ get; private set; } If we have two threads and the first is calling 'get' and the second is calling 'set' at the "same" time, what will happen? IMHO the set must made a lock to be thread-safe ...

Building a WPF UI on a workerthread?

I have to buil a rather complex WPF UI (a hughe Grid) in code (no xaml invloved). Is there a way to stop the main UI thread from blocking while beeing in the process of building the Grid? Are there some portions of building the UI that can be outsourced to a workerthread? What parts of UI creation actually have to be on the UI thread? ...

Is ASP.NET multithreaded (how does it execute requests)

This might be a bit of a silly question but; If I have two people logging on to my site at exactly the same time, will the server side code be executed one after the other or will they be executed simultaneously in separate threads? I'm curious in regards to a denial of service attack on a website login. Does the server slow down becau...

Code for a simple thread pool in C#

Looking for some sample code (C#) for a simple thread pool implementation. I found one on codeproject, but the codebase was just huge and I don't need all that functionality. This is more for educational purposes anyways. ...

Keep app responsive during long task

A certain form in our application displays a graphical view of a model. The user can, amongst loads of other stuff, initiate a transformation of the model that can take quite some time. This transformation sometimes proceeds without any user interaction, at other times frequent user input is necessary. While it lasts the UI should be dis...

Thread ListBox C# SharpDevelop

Hi everyone. I'm trying to use a Thread in a simple winform. I have a ListBox which I want to fill with numbers at the form's load method. I don't want to wait until it is filled. I'm using something like this: void fillList() { Invoke(new MethodInvoker( delegate { while(true) { i++; ...

Delphi IDE hangs while debugging threads

This is kind of a follow-up question to this. When I'm debugging threads in Delphi (BDS 2006 with update 2) my IDE often hangs, e.g. when the execution runs into a breakpoint that I have set after the app started. Do you have similar experiences? What do you do about it? ...

FIFO queue synchronization

Should FIFO queue be synchronized if there is only one reader and one writer? ...

Why does .exe refuse to stop?

Hi there, I've "inherited" a legacy C#/C++ program that I have to debug. The current problem is that the .exe won't stop after I close the program, i.e. it still shows up in Task Manager. This is a problem, because it won't let me restart the program, because only one instance can run. Often killing the process doesn't work; I'm forc...

Can object constructor return a null?

We have taken over some .NET 1.1 Windows Service code that spawns threads to read messages off a queue (SeeBeyond eGate JMS queue, but that is not important) and in turn spawns threads to process the message in the target application service. We are continually encountering logic and design decisions that is puzzling us to no end. Here i...

What can cause a .NET process/thread to terminate unexpectedly?

I'm trying to gather a complete listing of the reasons a .NET process or thread to terminate, even though the main() method is guarded by a try...catch clause. One such reason is Thread.Abort() (unless you call Thread.ResetAbort). Do you know of more reasons? ...