multithreading

Allegro 5 game: game loop that runs at constant speed?

What is the best way to code a game loop in Allegro 5 that always runs at the same speed, and that properly separates drawing logic from update logic? Should I use threads or not? Should I make use of the new Allegro event system? ...

Python Interpreter blocks Multithreaded DNS requests?

Hello everyone, I just played around a little bit with python and threads, and realized even in a multithreaded script, DNS requests are blocking. Consider the following script: from threading import Thread import socket class Connection(Thread): def __init__(self, name, url): Thread.__init__(self) self._url = url ...

context deadlock switching in a windows service

Hi, Is it possible to get a context deadlock switching exception in a windows service? JD. ...

Threads that return data in .NET

I'm writing a program where I typically start five threads. The threads return in a non-determinate order. Each thread is calling a method which returns a List. I'm doing this: var masterList = List<string>(); foreach (var threadParam in threadParams) { var expression = threadParam ; ThreadStart sub = () => MyMethod(express...

Difference between event object and condition variable

What is the difference between event objects and condition variables? I am asking in context of WIN32 API. ...

Java: Complete code examples of thread-per-connection blocking IO versus NIO?

Ok, I'm going crazy here. I have been rewriting the NIO code for my server, and running into some real headaches. The bottom line is that getting NIO "right" is very hard. Some people pointed me to the Rox tutorial at http://rox-xmlrpc.sourceforge.net/niotut/, which seems to be on a good path, but is not as complete as I would like. ...

Is it legal to call the start method twice on the same Thread?

The following code leads to "java.lang.IllegalThreadStateException: Thread already started." the second time it is run through on the program. updateUI.join(); if (!updateUI.isAlive()) updateUI.start(); This happens the second time updateUI.start() is called. I've stepped through it multiple times and the thread is called ...

NSURLConnection delegation and threading - iPhone

I have a class that updates two .plist files in the app documents directory via an NSURLConnection. The class acts as its own delegate for NSURLConnection. It works properly when I ask for a single file, but fails when I try to update two files. Does it look like I should start a new thread for each of the getNewDatabase messages? - ...

Invoking methods in QThread's context

In my application there's the main thread and a worker thread (QThread). From the main thread I'd like to invoke a method of my worker thread and have it run in the thread's context. I've tried using QMetaObject::invokeMethod and give it the QueuedConnection option but it's not working, I've also tried emitting signals from the main thre...

C# WinForm Application - UI Hangs during Long-Running Operation

I have a windows forms application on which I need to use a for loop having a large number of Remote Calls around 2000 - 3000 calls, and while executing the for loop, I loose my control on form and form controls, as it becomes a large process and some time it shows "Not Responding" but if I wait for a long it comes back again, I think I...

Parallel software?

What is the meaning of "parallel software" and what are the differences between "parallel software" and "regular software"? What are its advantages and disadvantages? Does writing "parallel software" require a specific hardware or programming language ? ...

Understanding POSIX Threads

I have some confusion with POSIX Threads, I want to know if my understanding of Pthreads is proper, According to me its a layer above the native layer which helps in dealing with multithreading. It provides a common syntax, which helps while porting from one OS to other. It internally takes care of the various OS specific constructs. ...

Efficient data conversion using .Net

I am working on an application that will need to read tons of records (close to 500,000) from one table and insert them into another set of tables in the same database. I though about using SSIS package for this but our DBAs don't want to use that. Now, I am thinking of a multi-threaded approach. I am thinking that I can have a few th...

Following code errors out at the line commented with "---errors is here---". What is wrong?

using System; using System.Threading; public class MutexSample { static Mutex gM1; static Mutex gM2; const int ITERS = 100; static AutoResetEvent Event1 = new AutoResetEvent(false); static AutoResetEvent Event2 = new AutoResetEvent(false); static AutoResetEvent Event3 = new AutoResetEvent(false); static AutoR...

Implementing condition variables for CRITICAL_SECTIONs for Winthreads for XP

I have a desire for POSIX style condition variables on Win32. I have some code that needs to run on XP, so I can't use Vista/Server 2008's CONDITION_VARIABLE. It makes use a of a pseudo condition variable class currently, which is based on leaving the critical section and signaling an auto reset event for signaling / waking. For waitin...

How to isolate your program from calls to a "bad" API?

When I developed a piece of (academic) software using Java, I was forced to use an API that was rather badly implemented. This means that calls to this API for a certain set of input data would sometimes never return. This must have been a bug in the software as the algorithms that it offered were deterministic ones, and sometimes it wou...

Does a lock on a mutex also apply to called functions?

If a mutex is defined within a function, does its lock apply to functions called from that function? ie void f () { Mutex mutex; g(); } Does the lock still apply to any data modifications in g()? Also, am I right to say that a lock defined in a class method will only apply to specific instances of that class? Meaning: ...

Portable thread-safety in C?

Purpose I'm writing a small library for which portability is the biggest concern. It has been designed to assume only a mostly-compliant C90 (ISO/IEC 9899:1990) environment... nothing more. The set of functions provided by the library all operate (read/write) on an internal data structure. I've considered some other design alternatives,...

Why does a worker thread not execute when debugging the main thread?

I have created a console test application which creates, an object & calls 2 functions on 2 separate threads. One thread prints numbers form 1- 20 the other in the reverse order. The problem is while debugging the 1st worker thread does not get fired till I don't stop debugging the main thread (i.e. I press f5). Any answers? class Prog...

Do I need to lock or mark as volatile when accessing a simple boolean flag in C#?

Lets just say you have a simple operation that runs on a background thread. You want to provide a way to cancel this operation so you create a boolean flag that you set to true from the click event handler of a cancel button. private bool _cancelled; private void CancelButton_Click(Object sender ClickEventArgs e) { _cancelled = tru...