multithreading

boost::this_thread::disable_interruption usage confusion

boost/thread/pthread/shared_mutex.hpp contains this code: ... #include <boost/thread/detail/thread_interruption.hpp> ... class shared_mutex { ... void lock_shared() { boost::this_thread::disable_interruption do_not_disturb; boost::mutex::scoped_lock lk(state_change); while(state.exclusive || state.e...

How to measure Java thread execution time?

Hey, I want to measure thread execution time in Java. Now I'm monitoring thread start and end times, but I think it's not so accurate because thread could be suspended during it execution. ...

Thread Suicide on Shutdown? stopping java.util.Timer instance

I have a java.util.Timer running at a fixed interval. I have added a Runtime#addShutdownHook and it shuts down when the VM ends normally or abnormally. However, it keeps the VM alive when a main terminates, unless I insist by doing a System.exit in the main. Is there any way for me to check if I'm the last Thread standing, or some other ...

Periodically updating data in a matplotlib figure embedded in a QWidget

I have a thread that updates some data periodically. I want do visualize the data with matplotlib. When the thread updates the data, the plot should be updated as well. I tried embedding a matplotlib.FigureCanvas(see following snippet) in a QWidget... class MplSubPlotCanvas(FigureCanvas): def __init__(self, parent=None): se...

Abort call to unmanaged DLL

I have an unmanaged DLL with a function that can run for a long time if the input parameter is a large value, sometimes that is desirable but not always. How can I in c# call this function so that I can abort it when needed? So far I have tried to put the call in a separate thread, but neither interrupt nor abort seem to stop the proce...

VC++ - Asynchronous Thread

I am working on VC++ project, in that my application process a file from input path and generates 3 output "*.DAT" files in the destination path. I will FTP these DAT file to the destination server. After FTP, I need to delete only two output .DAT files the folder. I am able to delete those files, because there one Asynchronous thread ru...

Simple Thread Programming

I have started to play with threads in c#, but need now help, here is my code: public partial class Form1 : Form { public Form1() { InitializeComponent(); DoCount(); } public void DoCount() { for (int i = 0; i < 100; i++) { objTextBox.Text = i.ToString(); Thr...

Why should Java ThreadLocal variables be static

I was reading that JavaDoc for Threadlocal here http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ThreadLocal.html and it says "ThreadLocal instances are typically private static fields in classes that wish to associate state with a thread (e.g., a user ID or Transaction ID). " But my question is why did they choose to make it static ...

Writing to a log4net FileAppender with multiple threads performance problems

TickZoom is a very high performance app which uses it's own parallelization library and multiple O/S threads for smooth utilization of multi-core computers. The app hits a bottleneck where users need to write information to a LogAppender from separate O/S threads. The FileAppender uses the MinimalLock feature so that each thread can lo...

CollectionChanged notification across threads?

I'm writing a download manager using C#/WPF, and I just encountered this error: This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread. The basic flow of my program is that a few web pages/downloads are enqueued at the start, and then they're downloaded asynch...

OCCI createEnvironment Blocks My Thread

Hello, I'm writing a multi-threaded application, where there is a main thread which distributes tasks to the worker threads. According to the task, a worker thread creates a connection, by using a global occi environment. When a worker thread completes its task, it closes the connection (I'm sure, there is no exception thrown while ter...

Crash using WscRegisterForChanges.

I'm trying to use the WscRegisterForChanges with C++ function in Windows 7. Documentation located here: http://msdn.microsoft.com/en-us/library/bb432507(v=VS.85).aspx My problem is that even though the callback properly executes, the code crashes when it gets to the end of the callback's execution. Here's the code in question. It's ...

Does the managed main UI thread stay on the same (unmanaged) Operation System thread?

I am creating a managed WPF UI front-end to a legacy Win32-application. The WPF front-end is the executable; as part of its startup routines I start the legacy app as a DLL in a second thread. Any UI-operation (including CreateWindowsEx, etc.) by the legacy app is invoked back on the main UI-thread. As part of the shutdown process of th...

How to demonstrate java multithreading visibility problems?

If variables in Java are accessed from multiple threads, one must ensure that they are safely published. This usually means using synchronizedor volatile. I have got the impression, that some of my colleagues do not take this issue seriously, since they "never heard of volatile before and their programs have worked for years". So my qu...

Python: Huge file reading by using linecache Vs normal file access open()

Hi, I am in a situation where multiple threads reading the same huge file with mutliple file pointers to same file. The file will have atleast 1 million lines. Eachline's length varies from 500 characters to 1500 characters. There won't "write" operations on the file. Each thread will start reading the same file from different lines. Whi...

What are Erlang processes behind the scenes?

I've got very limited knowledge about Erlang, but as far as I understand, it can spawn "processes" with a very low cost. So I wonder, what are those "processes" behind the scenes? Are they Fibers? Threads? Continuations? ...

Should I Put Critical Section While Getting Connection from OCCI Environment

Hello, I'm writing a multi-threaded application. My worker threads get connection from an environment object as follows:. //EnterCriticalSection(&cs); conn = env->createConnection(username, password, connStr); //LeaveCriticalSection(&cs); For concurrency, should the connection be created in a critical section or not? Does the env nee...

Is there a Form.Invoke() method?

Hi, I am new to multithreading (and also to C#) so I hope this is not obvious: In my Form (WinForms application, .NET 2.0) I subscribed to an event that is raised by another object, and on handling this event I wish to change several Controls on my Form. As this event is raised in another thread than the main (UI) thread I want to mars...

Is this BlockingQueue susceptible to deadlock?

I've been using this code as a queue that blocks on Dequeue() until an element is enqueued. I've used this code for a few years now in several projects, all with no issues... until now. I'm seeing a deadlock in some code I'm writing now, and in investigating the problem, my 'eye of suspicion' has settled on this BlockingQueue<T>. I can't...

Multithreaded python script silently dies - how to debug

I have a python script that creates and starts 3 threads, and then goes to a KeyboardInterrupt-catching-loop, to send the threads stop signal when ctrl+c is pressed. The threads' run method has a top level try-except which logs every exception, also the top level code that creates threads is wrapped into try-except to log every exceptio...