multithreading

Killing all thread workers when one thread found the answer (ruby)

Here is a sample program: def worker(from, to) puts "#{from}..#{to}" for i in from..to do if i == 42 puts "kill the rest of the threads" break; end puts i sleep 1 end end if __FILE__ == $0 threads = [] for i in 0..9 do threads << Thread.new { worker(i*10, i*10+10) } end threads.each { |th...

WPF multithreading

I'm scratching my head in trying to get the multithreading to work as I want in WPF I have an object (with a singleton) called Manager which does alot of processing and lookups. I want it to run in a separate thread from the UI, The UI will call methods on Manager to do the processing and fire events that the UI should react to I'm con...

Why is my MFC DLL deadlocking on a single thread near startup?

Using Visual Studio 2005, the debugger tells me that a deadlock has occurred just after startup of the app I'm writing - I'm well in to WinMain() at this point. The callstack shows that we are in a critical section, while calling AFX_MANAGE_STATE2 (for the 666th time, spookily enough) from within an MFC DLL. This has just started happe...

TestNG multithreaded test with Spring @Transactional

I am using TestNG to test persistence Spring modules (JPA+Hibernate) using AbstractTransactionalTestNGSpringContextTests as a base class. All important parts @Autowired, @TransactionConfiguration, @Transactional work just fine. The problem comes when I am trying to run test in parallel threads with threadPoolSize=x, invocationCount=y Te...

Python: deferToThread XMLRPC Server - Twisted - Cherrypy?

This question is related to others I have asked on here, mainly regarding sorting huge sets of data in memory. Basically this is what I want / have: Twisted XMLRPC server running. This server keeps several (32) instances of Foo class in memory. Each Foo class contains a list bar (which will contain several million records). There is...

What are the advantages of instance-level thread-local storage?

This question led me to wonder about thread-local storage in high-level development frameworks like Java and .NET. Java has a ThreadLocal<T> class (and perhaps other constructs), while .NET has data slots, and soon a ThreadLocal<T> class of its own. (It also has the ThreadStaticAttribute, but I'm particularly interested in thread-local ...

Perl - Save sockets in a hash and loop it from a thread

I am working on a mulithreaded TCP server. In the main thread i listen on a socket and create a new thread for new incomming connections. I want to save all incoming connections in a hash so that i can access them from yet another thread. From the "monitor" thread i can not read any newly added connections. It seems a new "clients" hash...

Multi-Threaded Update Server

We are wanting to replace our current update system for the POS software at our stores. Currently, we have a folder on our webserver that hosts a script that our registers call every 30 minutes or so. They pass in their current version number, and the server returns an XML response containing any files that need to be updated, hash, an...

What does setting Thread.Priority = Lowest really mean?

In an effort to speed up the startup of my resource-hungry app, I've moved various startup tasks to background threads and marked those thread with 'Thread.Priority = Lowest`. However, those low priority threads still execute pretty much in parallel with the application (as it loads its UI), as evidenced by the timeline on the ANTS Prof...

Advice for converting a large monolithic singlethreaded application to a multithreaded architecture?

My company's main product is a large monolithic C++ application, used for scientific data processing and visualisation. Its codebase goes back maybe 12 or 13 years, and while we have put work into upgrading and maintaining it (use of STL and Boost - when I joined most containers were custom, for example - fully upgraded to Unicode and t...

Java Concurrency: lock effiency

Hello My program has 100 threads. Every single thread does this: 1) if arrayList is empty, add element with certain properties to it 2) if arrayList is not empty, iterate through elements found in arrayList, if found suitable element (matching certain properties), get it and remove the arrayList The problem here is that while one th...

Why isn't ThreadPool.GetAvailableThreads working?

I have a method to process the rows from a datatable using multiple threads, it queues up all the work items and then checks that they have all been processed, not leaving the method until they have. It seems to work fine in development, but when I put in onto the server (64-bit) for testing, it will not wait at the end of the method. ...

Backgroundworker threads not closing on program close ?

I have a simple program that has backgroundworkers, and it runs with no stop, and no matter when I close it, it will always have some still running (or all of them) and I've noticed that closing the application doesn't completly kill it. After running it some times, there are processes (1 for each run) that remain on the process tab of t...

Performance problem with backgroundworkers

I have 15 BackgroundWorers that are running all the time, each one of them works for about half a second (making web request) and none of them is ever stopped. I've noticed that my program takes about 80% of my computer's processing resources and about 15mb of memory (core 2 duo, 4gb ddr2 memory). It it normal? web requests are not hea...

How do I safely use ADO.NET IDbConnection and IDbCommand to execute multiple database commands concurrently?

The Goal Use an ADO.NET IDbConnection and IDbCommand to execute multiple commands at the same time, against the same database, given that the ADO.NET implementation is specified at runtime. Investigation The MSDN Documentation for IDbConnection does not specify any threading limitations. The SqlConnection page has the standard disclai...

Why does my windows console application leak when idling? (And why does the smoking gun point at kernel32.dll??)

Hello everyone. I have a windows multi-threded console application that appears to be leaking approximately 4kb private memory every minute or so. In an effort to localise the leak, I have gradually suspended each thread in the application until the leak stopped, and to my surprise the culprit seems to be a thread named "Win32Thread". ...

how to preload images in a background thread?

In my WPF app i need to load some images. I only need to display one image at a time. If i load the image when it's needed, there is a slightly delay. So i thought to myself: "Hey, why not do some preloading in a background thread? Can't be that hard." I have some experience with threads, but not enough to know that this thought was wron...

Object synchronization with using ThreadPool

I have multiple processor objects which I use with ThreadPool to use them in a paralel process. Which processor I am going to use is basically depend on the incoming data and there might be more than 2000 different types; so as soon as my app runs it creates 1-2K number of processors in a dictionary and run the one I need according to in...

Should I use ruby threads or just not use ruby altogether for threading?

I have a choice to develop an app which will rely heavily on threading (up to to 200). I know I can use other Ruby interpreters for threading such as JRuby. But there are 2 things: 1) Jruby doesn't support 1.9 yet, so that is a no. Is there any other non-green thread interpreter that supports at least 1.9 as that is a prerequisite for m...

How do I suspend another thread (not the current one)?

I'm trying to implement a simulation of a microcontroller. This simulation is not meant to do a clock cycle precise representation of one specific microcontroller but check the general correctness of the code. I thought of having a "main thread" executing normal code and a second thread executing ISR code. Whenever an ISR needs to be ru...