multithreading

Is concurrently overwriting a variable with the same value safe?

I have the following situation (caused by a defect in the code): There's a shared variable of primitive type (let it be int) that is initialized during program startup from strictly one thread to value N (let it be 0). Then (strictly after the variable is initialized) during the program runtime various threads are started and they in so...

coldfusion threads: looping session variables + sleep

hey guys I'm trying to create a timer which counts the time spent on a page using a thread heres what I have so far: <cfset session.time=0> <cfthread name="timer" action="run"> <cfscript> counter = 0; while (counter <9000) { sleep(1000); session.time++; counter ++; } </cfscript> </cfthread> page 2: <cfoutput>#session...

Advanced Books for Windows Form and WPF Programming

Can someone recommend me the best books for windows form and WPF Advanced issues (e.g., threading model in those technology.)? Thanks. ...

Need to know if my threading lock does what it is supposed to in .Net?

I have an application that, before is creates a thread it calls the database to pull X amount of records. When the records are retrieved from the database a locked flag is set so those records are not pulled again. Once a thread has completed it will pull some more records form that database. When I call the database from a thread shou...

Update UI from parent class on different thread from secondary class

I have a parent class which builds my UI (basically just a text box at the moment). I have created a secondary class which creates a new thread and I need to be able to update the textbox on the parent class from the new thread. Everything I try throws errors. I'm assuming I need to create some kind of dispatcher but my background is ...

Multithreaded Search using c#

Hi All I want to seach more than 15000 values in a select statement as shown below: select * from tableA where id in (1,2,3......16000) Can I use threads, say around 3, and partion 15000 values in diffrent select statement. select * from tableA where id in (1,2,3......5000) select * from tableA where id in (5001....10000) select * f...

Locking to modify static value-type member. Is it necessary?

I have a CacheHelper class to facilitate interaction with the cache. I want to use a static int field to specify my cache timeout. The field is initially set to a const default value but I want to provide a way for the application to change the default timeout value. Do you need to lock when modifying a static value type? Is the lock i...

twisted + gtk: should I run GUI things in threads, or in the reactor thread?

From what I understand about twisted, nothing running in the reactor thread should block. All blocking activities should be delegated to other threads, to fire callbacks back into the reactor thread when they're done. So does this apply to gtk things as well? For example, I want to display a "connection failed" message if the connection...

Process spawned through Process.Start in .NET hangs the thread

Our application has a background thread which spawns a process through System.Diagnostics.Process: Process.Start( new ProcessStartInfo { FileName = url, UseShellExecute = true } ); This used to have no issues at all. But now, the background thread is silently dying; it never returns from the call to Proces...

ObjectDisposedException when I abort a thread that's writing to the serial port

I've written an application with a plug-in feature, and if a plug in doesn't respond quickly to a stop request, I call Thread.Abort() on its worker thread. This seems to work most of the time, but I recently discovered that it throws an ObjectDisposedException if the thread is aborted while it's writing to the serial port. With some USB-...

Empty while loop not checking condition

In a multithreaded C++ program, I have the equivalent of this running in one thread: while(obj->member) { } // waiting for obj->member to be set to false in another thread and in another thread, obj->member is set to false. Even when it's set to false, however, the loop doesn't break. If I change it to this: while(obj->member) { Slee...

PyQt4 Threading: Sending data back to a thread

I'm writing a program, with a PyQt frontend. To ensure that the UI doesn't freeze up, I use QThreads to emit signals back to the parent. Now, I have reached a point where I need my thread to stop running, emit a signal back to the parent, then wait on the parent to return an approval for the thread to continue (after the user interacts...

What is blackberry's equivalent to Androids Looper?

Android has Looper, and iPhone has Run Loops. It seems like Blackberry would have a similar backed in facility to queue and run threads. Does anyone know if there is? ...

System.Timers.Timer freezes when UI thread freezes in Windows XP

Hello. You most likely are aware that a System.Windows.Forms.Timer freezes its action when the user interface thread also freezes, that happens because they run in the same thread. That forced me to use a System.Timers.Timer which in turn if the user interface freezes the Timer continues to run its usual process like nothing ever happe...

Multiple threads accessing singleton object in VS2010

I'm using Visual Studio 2010 to write a simple C#/.NET GUI app, wherein I use a Logger class to write tracing/debugging info to a single file from within all of the various classes of the project. (See source code below.) Each class's constructor writes an entry to the log when one of its object types is instantiated. One of those class...

paper on event-based v.s. threaded programing

I am trying to tap into the stackoverflow community to aid my fogged memory. A while ago I have read a research paper regarding multithreading v.s. event-base programming paradigm. The thesis is to challenge the current belief that multithreading has a natural limit on the number of threads a system is able to support. It asserts such li...

C# Wait and multithreading

Simple enough question, I just need to break through one minimal wall of confusion. So based on the simple code below: Task task1 = new Task(() => { for (int i = 0; i < 500; i++) { Console.WriteLine("X"); } }); task1.Start(); t...

Recommended language for multithreaded data work

Right now, I use a combination of Python and R for all of my data processing needs. However, some of my datasets are incredibly large and would benefit strongly from multithreaded processing. For example, if there are two steps that each have to performed on a set of several millions of data points, I would like to be able to start the...

Write to a file from multiple threads asynchronously c#

Hey all, Here is my situation. I would like to make writing to the file system as efficient as possible in my application. The app is multi-threaded and each thread can possibly write to the same file. Is there a way that I can write to the file asynchronously from each thread without having the writes in the different threads bang h...

Is a single Java thread better than multiple threading in my scenario?

Our company is running a Java application (on a single CPU Windows server) to read data from a TCP/IP socket and check for specific criteria (using regular expressions) and if a match is found, then store the data in a MySQL database. The data is huge and is read at a rate of 800 records/second and about 70% of the records will be matchi...