multithreading

Is reading data in one thread while it is written to in another dangerous for the OS?

There is nothing in the way the program uses this data which will cause the program to crash if it reads the old value rather than the new value. It will get the new value at some point. However, I am wondering if reading and writing at the same time from multiple threads can cause problems for the OS? I am yet to see them if it does....

Are there any automated unit testing frameworks for testing an in-house threading framework?

We have created a common threading framework to manage how we want to use threads in our applications. Are there any frameworks out there like gtest or cppunit that solely focus on unit testing threads, thread pools, thread queues, and such? Right now I just kind of manually go through some steps that I know I should cover and do check...

In what thread does a low-level mouse and keyboard hook callback run?

I'm setting a low-level mouse hook with SetWindowsHookEx: HANDLE handle = SetWindowsHookEx(WH_MOUSE_LL, &callback, GetModuleHandle(NULL), NULL); Because this is a low-level callback, it will be executed inside my own process; no DLL injection is performed. Now, I've noticed that the callback sometimes (indirectly) gets invoked from s...

Cocoa, Windows and Threads?

On windows, each thread has a message queue, and each message queue will process messages for the windows owned by that thread. This means that it is quite simple to write an application where you can create a thread, with a message loop, and one (or more) windows. Ignoring any kind of application issues, one now has application windows ...

Thread-local, class instance-local storage?

Is there a good, platform-agnostic way to implement a variable that's local to both a thread and a class instance, i.e. if you have T threads and I class instances, you have TxI instances of that variable? I'm using the D programming language, version 2, but a good language-agnostic answer would also be useful. Here are some constraint...

.NET - Thread sychronization

Hello, I've been working on a thread which will live aslong as the application is running, and runs at a interval of 500ms. I noted that i could be uselessly processing if there's nothing in the queue for it to process, so i went around looking at some sources i had locally, and i found an example close to mine, but it's in Java. The ...

openssl BF_cfb64_encrypt thread-safety

Is openssl's BF_cfb64_encrypt() thread safe? A sample code to use it to encrypt / decrypt a blob of data would be much appreciated. ...

Can a read-write conflict provokes an infinite loop?

Hi, Say there's a statement waiting for a variable to be updated by another thread. #in thread1: while (flag == 0); Without using any kind of lock, there might be a read-write conflict if one thread reads the variable while it's being updated by another one. #in thread2: flag = 1; Can this lead to an infinite loop? or is the conf...

What is most CPU efficient method to make the worker threads wait for tasks?

In my current C#/NET 3.5 application, I have a task queue (thread safe) and I have 5 worker threads that has to constantly look for tasks in the queue. If a task is available, any one worker will dequeue the task and take required action. My worker thread class is as follows: public class WorkerThread { //ConcurrentQueue is my impl...

Problem with Multi - thread Parameters using delegate in compact framework

My issue is that I have a List of strings, and I want to create one thread for one string, pass the string into the thread. This is my code: public void getImageSource(List<string> UrlLinks) foreach (string urlLink in UrlLinks) { ThreadStart myThread = delegate { Fetch(urlLink); }; ...

Spring Tests : transaction not rolling back after test method executed

Hi ! I'm trying to create integration tests for a legacy application deployed on Weblogic 8.1 using a subclass of AbstractTransactionalJUnit4SpringContextTests. My test method has the following annotations : @Test @Rollback(true) public void testDeployedEJBCall throws Exception {...} My test class also references beans of type org.s...

What would happen in an thread unsafe .NET queue object?

I have a .NET queue object. The producer thread do the Enqueue operation, the data enqueued in the queue is a byte[] array, while the other consumer thread do the Dequeue operation on the same queue object. I use locks to handle concurrency. My code seems to work fine all the time, but yesterday, weird things happened. The data I got fr...

Threads and semaphores in Ada95

How can I use threads in Ada95? What functions can I use to create, destroy, stop and start them? How can I use semaphores in this language? ...

What can cause Application.Run() to stop blocking?

My winforms application does something like the following: * Please note, the code below works as expected and blocks on singleInstance.Run(new string[0]{}); I haven't been able to reproduce the problem outside of my application static class Program { /// <summary> /// The main entry point for the application. /// </summar...

Collection was modified; enumeration operation might not execute.

hi all how r u i faced problem with datatable when i run to client it throw exception and mention the "in" in foreach. Collection was modified; enumeration operation might not execute. this is the code plz help: foreach (DataRow dr in stStatusTable.Rows) { if (Convert.ToInt32(dr["st_id"]) == stStatus.st_id) { dr["st_id"...

Processing a flat file in chunks using multiple threads using producer/consumer pattern and SqlBulkCopy into SQL Server DB

I hope you will bear with me. I wanted to provide as much information as I can. The main problem is how to create a structure (like a stack) that will be used by multiple threads that will pop a value and use it to process one big flat file and possibly do cycling again and again until the whole file is processed. If a file has 100.000...

How do garbage collection and background threads interact in .NET?

Let's say I create an object, and that object starts a thread, and gives one of its private instance methods to ThreadStart. Later, all references to that object are gone. What happens? Is the object is never garbage collected because the thread holds a reference to it through the this pointer? On the other hand, if I use a static method...

GUI not updated from another thread when using PyGtk

I am using PyGTK to build a GUI application. I want to update the textview widget from another thread but the widget is not getting updated everytime i try an update. What should i do to get a reliable GUI updating? ...

Efficient File I/O and Conversion of Strings to Floats

I have some gigantic (several gigabyte) ASCII text files that I need to read in line-by-line, convert certain columns to floating point, and do a few simple operations on these numbers. It's pretty straightforward stuff, except that I'm thinking that there has to be a way to speed it up a whole bunch. The program never uses the equival...

pthread vs NSThread: which is faster

In Cocoa, is NSThread faster than pthread? is are any performance gain? is it negligible to ignore? ...