multithreading

Thread Local Storage

When you allocate some TLS for thread A in a slot, can you then access that same slot from Thread B? Is it internally synchronized or how does that work? ...

What hardware interrupts are actually interrupt?

Possible Duplicate: How do interrupts in multicore/multicpu machines work? what is interrupted by a hardware interrupt? one particular CPU core execution or all CPUs in the system? The CPU is i7 or Xeon X3450 ...

What is the best approach to thread-safe multiple parallel readers threads and occasional writer thread on an ArrayList object to a C# application?

Consider the scenario below: The application is multi-threaded and it has one static ArrayList used globally. The application has one thread that reconstruct the ArrayList entirely from data read from database from time to time. The application has N threads reading from this global ArrayList in parallel. What is the best approach to...

Is 'synchronized' really just syntactic sugar?

I am new to multithreading, and I wrote this code which prints the numbers 1-10000 by having concurrently running threads increment and print a variable. Here's the code I'm using: package threadtest; public class Main{ static int i=0; static Object lock=new Object(); private static class Incrementer extends Thread{ ...

Multithreading in C++ ... where to start?

I'd like to start learning multithreading in C++. I'm learning it in Java as well. In Java, if I write a program which uses multithreading, it will work anywhere. However in C++, doesn't multithreading rely on platform-specific API's? If so, that would seem to get in the way of portability. How can I do multithreading in C++ without cau...

Reading and writing with the same Access '97 table: Thread safety problems?

I am maintaining a program that reads records from a Access '97 table using a Timer. A different program outside my control writes records to this table. So the reading and writing is not synchronized. I am wondering if this could occasionally lead to data corruption. Writing a testing environment is difficult for several reasons. Does s...

How can I make a third-party library thread-safe for use with Boost threads?

I am using a third-party C++ library (OpenFst), which is not particularly designed to be thread-safe. It does have some unused Mutex classes in there, though. Now I would like to call some functions from that library and run them in Boost threads. How can I do that? Do I just have to write additional Mutex classes? In particular, some ...

Why use select() instead of sleep()?

I'm working through a chapter about iPhone audio and have come across a section of code that I can't make sense of: while (aqc.playPtr < aqc.sampleLen) { select(NULL, NULL, NULL, NULL, 1.0); } (Full code sample is on pages 163-166). From what I understand of the code the audio is being processed on another thread and the while lo...

How to do QObject::moveToThread() when using QThreadPool?

I'm building a small multithreaded web server. The QTcpSockets are fetched in the main thread and then hand over by QtConcurrent to the QThreadPool, which eventually processes the data and sends out an answer. My problem is that the socket is created in the main thread and processed in another one. This causes errors when trying to writ...

Multithreading: What is the point of more threads than cores?

Perhaps this is a total noob question, but: I thought the point of a multi-core computer is that it could run multiple threads simultaneously. In that case, if you have a quad-core machine, what's the point of having more than 4 threads running at a time? Wouldn't they just be stealing time from each other? ...

Why do the threads run serially in this console application?

hi, I'm creating an console application which needs to run several threads in order to accomplish a task. My problem is that threads are running one after another (thread1 start -> work -> end and ONLY then start thread2) instead of running all in the same time. Also i don't want more than 10 threads to work in the same time(performance...

ASP.NET + thread-aware unmanaged API

I'm thinking over an ASP.NET application that uses ESENT for persistance. At this point this is just my hobby project, so the requirements are very flexible. However I'd like it to work on Windows 7, Windows 2008, and 2008 R2, with .NET 3.5 and higher, and default IIS settings. In ESENT, most operations require you to open a session o...

Tips to write thread-safe UNIX code?

What are the guidelines to write thread-safe UNIX code in C and C++? I know only a few: Don't use globals Don't use static local storage What others are there? ...

QThread and QRunnable - Simple multithread GUI application

Hello. Is it possible in QT to run QRunnable from QThread object without blocking GUI? I was created new thread using class derivered from QThread and from this class I want to run many small functions. But GUI is loocking when I'm trying to run QRunnable. Could you give me some instruction how to do this or maybe some example how to do...

Thread issue in Android

I'm making a simple 2d game for the android platform, which works perfectly from version 2.0 and above, but when testing it on a 1.6 device, it crashes immediately. On running the debugger, it seems that I'm getting a null pointer exception in the thread class. I was just wondering if anybody has any ideas as to where the problem might b...

Designing a Thread Safe Class

When reading the MSDN documentation it always lets you know if a class is thread safe or not. My question is how do you design a class to be thread safe? I am not talking about calling the class with locking I am meaning I am working for Microsoft create XXX class\object and I want to be say it is "Thread Safe" what would I need to do? ...

Lock vs. ToArray for thread safe foreach access of List collection

I've got a List collection and I want to iterate over it in a multi threaded app. I need to protect it every time I iterate it since it could be changed and I don't want "collection was modified" exceptions when I do a foreach. What is the correct way to do this? Use lock every time I access or loop. I'm rather terrified of deadlock...

Static variables in IIS-hosted web applications

If I declare a static field in a type instantiated within an ASP.NET application, hosted within IIS, is the same variable (i.e. same memory location) used by all of the worker threads used by IIS, opening up concurrency issues? ...

Threading and static methods in C#

Here is a meaningless extension method as an example: public static class MyExtensions { public static int MyExtensionMethod(this MyType e) { int x = 1; x = 2; return x } } Say a thread of execution completes upto and including the line: x = 2; The processor then context switches and another t...

Static Thread Analysis: Good idea?

I help maintain and build on a fairly large Swing GUI, with a lot of complex interaction. Often I find myself fixing bugs that are the result of things getting into odd states due to some race condition somewhere else in the code. As the code base gets large, I've found it's gotten less consistent about specifying via documentation whi...