multithreading

Lock Ordering in C3p0

I am trying to log the creation and destruction of database connections in our application using c3p0's ConnectionCustomizer. In it, I have some code that looks like this: log(C3P0Registry.getPooledDataSources()) I'm running into deadlocks. I'm discovering that C3p0 has at least a couple objects in its library that use synchronized m...

Concurrency: Are Python extensions written in C/C++ affected by the Global Interpreter Lock?

One of Python's strongest points is the ease of writing C and C++ extensions to speed up processor intensive parts of the code. Can these extensions avoid the Global Interpreter Lock or are they also restricted by the GIL? If not, then this "ease of extension" is even more of a killer feature than I previously realized. I suspect the ans...

Profiling each thread in a multithreaded environment

Is there any way to find out the actual time spent by a thread inside the CPU using MFC/Win32? By actual time, I mean I don't want to count the time the thread spent in states other than "Running". I tried GetThreadTimes() method in Win32 SDK but couldn't get the proper values. I want to do this because I want to check effect of setting ...

WPF application in a loop, how to not have the whole application freeze?

Hello, I am having fun with WPF and got a problem. I have googled and found this website that has the same problem of me but without any working solution. The problem is that I have a button that do some processing of data (around 30 sec). I want to have the button to disable and to have log writing in a text box... the problem is that...

(More) Efficient locking when rotating nodes in threaded binary tree

So, I've come up with this scheme for locking nodes when rotating in a binary tree that several threads have both read and write access to at the same time, which involves locking four nodes per rotation, which seems to be an awfully lot? I figured some one way smarter then me had come up with a way to reduce the locking needed, but goog...

How to prevent the application timeout?

Hi, I have created a multithreaded application but it still hangs if the server is unavailable. In the main Activity I've created the following methods: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //bind GUI elements ... //start TC...

Shift Control from backgrount thread to main thread

Hi, I have thread that monitor the status of the device( using i/o ). This will fire the event to several UI (Forms/Dialogs..) parts about the connection status(Connected, Disconnected, Fault). Based on this status, the forms and dialogs are destroyed, created , enabled and disabled. My Problem : I getting Cross-Thread exception ...

How can I profile a multithread program in Python?

I'm developing an inherently multithreaded module in Python, and I'd like to find out where it's spending its time. cProfile only seems to profile the main thread. Is there any way of profiling all threads involved in the calculation? ...

How to implement multiple threads in Java

How do I implement multiple threads in Java? ...

Wanted: Cross-process synch that doesn't suffer from AbandonedMutexException

I have several threads that acquire Mutexes and then terminate. The mutexes are stored in a main repository, and are properly released when the program exists. However, when the thread that allocated a Mutex exists, the mutex gets released automatically, and subsequent acquire AbandonedMutexException (also according to the documentation...

What are some best practices for managing background threads in IIS?

I have written an HttpModule that spawns a background thread. I'm using the thread like a Scheduled Task that runs in-process, which is really handy. What are best practices for keeping track of this thread? I've never done this before, and I'm a little confused about some aspects of it: How do I know if the thread is still running...

How to properly kill local threads owned by a webapp running on tomcat instructed to shutdown

A backend webapp is deployed on a Tomcat 6 servlet container. In the webapp, several monitoring threads are started. The problem is with shutdown. How do I know that the webapp is requested to shutdown? How should I handle this in my threads? Currently my thread is implemented as below. When the servlet is instructed to shutdown (sh...

Multi-Threaded Client-Server Web Service - Making server side data thread-safe

Hi All I am implementing a multi-threaded web service. A thread is spawned per incoming request. For each client, a session is created and each session contains a data section - say a DOM tree. Client requests will basically be get/set methods and the server will read/write the DOM. So the DOM data is per client. Now my question is, s...

Want to thread a request to generate a page in ASP

Hello, I have an ASP.NET page that I want to be able to generate and save. The page takes a really long time to load, so I'd like to do it in a separate thread, while using the session of the user who requested the page (so that the page looks like it would if they viewed it themselves). Opening a new thread from code-behind breaks the...

Throttling speed of email sending process

Sorry the title is a bit crappy, I couldn't quite word it properly. Edit: I should note this is a console c# app I've prototyped out a system that works like so (this is rough pseudo-codeish): var collection = grabfromdb(); foreach (item in collection) { SendAnEmail(); } SendAnEmail: SmtpClient mailClient = new SmtpClient; mai...

How to avoid blocking (C++, Win32)

I'm making a dll that has to respond to an application's requests. One of the application's requirements is that a call should not take long to complete. Say, I have a function foo(), which is called by the host application: int foo(arg){ // some code i need to execute, say, LengthyRoutine(); return 0; } Lets say, foo has to perform ...

Execute a statement after thread gets over.

Hi, I am having a function where I have used a thread in c#.net. I am having a another function on the next line of that thread. But this function has to be called only after the thread gets executed. How can i do it ? Example.. Somefunction() { // thread //(thread started) add() (another function but need ...

How to prevent threads from dying or just quitting in C# .NET?

I am starting atmost 5 threads in a program in C# .NET. But sometimes some of those threads just quit or become dead inexplicably even before the completion of execution of the function assigned to it. It happens randomly . If I try to debug the code by putting breakpoints- It works fine. And sometimes all the threads execute the assig...

How is ASP.NET multithreaded?

I've been told that ASP.NET is multithreaded by default in IIS. How is this threading achieved? Does the server farm send different requests to different cores? Does a single request make use of multiple cores? More importantly, are there any advantages to adding threads to ASP.NET code if the threading is done higher up in IIS? ...

How does Intel TBB's scalable_allocator work ?

What does the tbb::scalable_allocator in Intel Threading Building Blocks actually do under the hood ? It can certainly be effective. I've just used it to take 25% off an apps' execution time (and see an increase in CPU utilization from ~200% to 350% on a 4-core system) by changing a single std::vector<T> to std::vector<T,tbb::scalable_...