multithreading

Thread safety of simultaneous updates of a variable to the same value

Is the following construct thread-safe, assuming that the elements of foo are aligned and sized properly so that there is no word tearing? If not, why not? Note: The code below is a toy example of what I want to do, not my actual real world scenario. Obviously, there are better ways of coding the observable behavior in my example. u...

Dividing workload on several threads

Hello. I was wondering if anyone knows about a good article which describes dividing workload on to several Threads? Preferebly it would be written for C# but it's really the concept I'm after, so it's not an issue if it's written for a different, similar, language. I have a problem where I would have to divide a large amount of comput...

Where to find Paint.NET multithreading white paper?

Like I wrote elsewhere, I seem to be sure that a white paper by Rick Brewster about multithreading used in Paint.NET once existed. I am not able to find any reference to this white paper again however. Does it (still) exist? And if so, where? EDIT: Found out in comments to an unrelated question that Paint.NET is still free, but code is...

Debugging a crash after exiting? (After main returned)

This is a fairly involved bug, and I've tried looking around to find other sources of help, but for reasons I don't understand, "Program Crashes in Vista" is not the most helpful query. The issue I'm having is that the program I'm working on - a graphical, multithreaded data visualization software that uses OpenGL and the Windows API - ...

java designing tasks in concurrent mechanism

I am coming up with a design for a task based multi-thread java 1.5 system. Tasks will generally interact with a collection to determine failed or successfull match events. Based on the outcome, another task may be queued for IO transactions to inform clients and/or store important information about the transaction. Java provides a ...

Thread communication using SendMessage

Hi, my question is : how can I use SendMessage() to implement thread communication between two threads, one with a window (GUI) and the other with no window? The problem is that SendMessage() needs a handle (HWND)? Another detail about my project : Two threads, one running managed code (the one with the user interface), and the other r...

When are constructors called?

If I define a local variable instance of a class halfway down my function without using a pointer and new, does the constructor get called on entering the function or where it is defined? If I define another instance of a class globally within the file does that constructor get called when executable is first loaded? What if multiple th...

ASP.NET thread switching

I read somewhere (I can't remember where) that it is possible, in certain circumstances, for an ASP.NET response to be switched, while being processed, between threadpool threads - sometimes in the middle of an executing method. Is this true? If so, how is this accomplished? If not, what could the author possibly have meant by this? ...

Why do locks work?

If the locks make sure only one thread accesses the locked data at a time, then what controls access to the locking functions? I thought that boost::mutex::scoped_lock should be at the beginning of each of my functions so the local variables don't get modified unexpectedly by another thread, is that correct? What if two threads are tryi...

[.NET] Using Thread.VolatileWrite() with array parameters

I want to use Thread.VolatileWrite() (or an equivalent function) to change the value of a T[] field, so that the updated value is immediately visible to all other threads. However, the method does not provide a generic version, and I'm not able to use the Object overload since it takes a ref parameter. Is there an alternative? Would Int...

c++; things to take care in multicore environment

What are all the things one needs to be careful about when coding in a multicore environment? For example, for a singleton class, it is better to create a global object and then return its reference than a static object. i.e Rather than having MyClass & GetInstance() { static Myclass singleMyclass; return singleMyclass; } It is be...

What's the best way to monitor a socket for new data and then process that data?

Please pardon my C#.Net newbie status. If this is obvious and I missed it from the docs, a link to the relevant page or sample code would be appreciated. I am working on an application that will accept a TCP socket connection from a Java application. (Yes, Java is required on that part. It's a Sun SPOT device and Java is the only option...

How to: Java listening for events captured by C thread.

I would like to create a Java program to listen for and respond to events captured by a thread in C. Can someone explain how this can be achieved using JNI, or point me to online tutorials? Thank you. ...

Design for multiple interacting timers

I'm designing a system that needs timers at all levels of a component hierarchy. Multiple timers may be active at once, but they need to interact with each other (stopping a component's timer stops its descendants' timers, while starting a component's timer starts its ancestors' timers and stops its siblings' timers). The timers each...

What kinds of applications need to be multi-threaded?

What are some concrete examples of applications that need to be multi-threaded, or don't need to be, but are much better that way? Answers would be best if in the form of one application per post that way the most applicable will float to the top. ...

How do you correctly update a databound datagridview from a background thread

I have a custom object that implements INotifyPropertyChanged. I have a collection of these objects where the collection is based on BindingList I have created a binding source for the collection, and set the datasources of the bindingsource and datagridview. Everything works great, except I need to update properties on the custom obje...

C++: Error handling problem across threads

In general I use exceptions to deal with errors, however the problem I have here is that the error applies to a different thread than the one that caused it. Basicly the window has its own thread, and the direct3d device must be created and reset by the same thread that created the window. However creating the device may fail, so I need...

Good example problems to solve with threading

I have used threads one or two times to try and boost the performance of my code, with varying degrees of success. It is obvious that I need some more experience working with multi thread code. Are there any good programming problems to solve which will help to get a grip on using multiple threads to improve performance? It would be nic...

What is wrong with my custom thread pool?

I've created a custom thread pool utility, but there seems to be a problem that I cannot find. using System; using System.Collections; using System.Collections.Generic; using System.Threading; namespace iWallpaper.S3Uploader { public class QueueManager<T> { private readonly Queue queue = Queue.Synchronized(new Queue()); private...

Insert Comment Reply Form Into Page Using Jquery

I have been making a threaded comment system as a way to learn php and javascript/jquery properly. Ive done bits and bobs in the past but ive made a new years resolution to learn it properly. Im having trouble inserting a reply form into the comment tree below the comment being replied to. I know this is probably pretty basic but how do...