multithreading

speed up operation on mysql

I'm currently writing java project against mysql in a cluster with ten nodes. The program simply pull some information from the database and do some calculation, then push some data back to the database. However, there are millions of rows in the table. Is there any way to split up the job and utilize the cluster architecture? How to do ...

What practical effect will different Ruby threading models (Ruby vs JRuby) have on your code as a developer?

I'm trying to understand the practical impact of different threading models between MRI Ruby 1.8 and JRuby. What does this difference mean to me as a developer? And also, are there any practical examples of code in MRI Ruby 1.8 that will have worse performance characteristics on JRuby due to different threading models? ...

"Red Cross" problem on MenuStrip and ToolStrip

Hi, I have a piece of software that has worked fine on many machines, althoughon one machine there is a problem that appears to occur occasionaly, the MenuStrip and the ToolStrip both appear as a blank white background with a red cross over it, as a custom control would if you created a null object. This doesn't happen whilst I am debug...

How use MultiThreading in VB.NET ?

I have example MultiThreading in VB. Net, I using thread to spider site,, I have a problem : I have to syncLock to lock sql query select top 1 link from tblSite where process = 0 and i update process = 1 , End SyncLock I spider content with links, and i update LastUpdate in DB, An Proces = 0... .. I do it slowly, can i help about p...

How to make a WPF control that updates every second?

This question is similar to another one I asked, but whereas in that case I wanted to know about forcing a binding to update from XAML or a view model, in this case I'd like to know about wrapping this up into a custom WPF FrameworkElement. The functionality I'm after is a span of text that indicates how long ago something happened. <T...

How to tell if a thread has exited successfully?

According to the MSDN Documentation for ThreadState, the Stopped state can be entered by one of two ways: the thread exiting, or the thread being aborted. Is there some mechanism for telling whether a thread has entered the Stopped state by exiting normally? Thanks! ...

Which scripting languages support multi-core programming?

I have written a little python application and here you can see how Task Manager looks during a typical run. While the application is perfectly multithreaded, unsurprisingly it uses only one CPU core. Regardless of the fact that most modern scripting languages support multithreading, scripts can run on one CPU core only. Ruby, Python,...

What is the cost of the volatile keyword in a multiprocessor system?

we're running into performance issues, and one potential culprit is a centralized use of a volatile singleton. the specific code is of the form class foo { static volatile instance; static object l = new object(); public static foo Instance { if (instance == null) lock(l) { if (instance == null) instan...

Not locking mutex for pthread_cond_timedwait and pthread_cond_signal ( on Linux )

Is there any downside to calling pthread_cond_timedwait without taking a lock on the associated mutex first, and also not taking a mutex lock when calling pthread_cond_signal ? In my case there is really no condition to check, I want a behavior very similar to Java wait(long) and notify(). According to the documentation, there can be ...

How to terminate a hanging thread inside a dll correctly?

Hi Everybody, I have a third party library that contains an error. When I call a function it may hang. The library function is called inside a dll. I decided to move the call into the thread and wait for some time. If thread is finished then OK. If not – I should terminate it compulsory. The simplified example here: unsigned Counter =...

Where can I find a good tutorial on iPhone/Objective c multithreading?

I'm just starting to use multithreading and was looking for a good explanation. I'm not sure if there are differences in how multithreading works on Macs and iPhones. Does anyone have a good link to tutorials with example code? Thanks. ...

Are java primitive ints atomic by design or by accident?

Are java primitive integers (int) atomic at all, for that matter? Some experimentation with two threads sharing an int seems to indicate that they are, but of course absence of evidence that they are not does not imply that they are. Specifically, the test I ran was this: public class IntSafeChecker { static int thing; static b...

ASP.NET MVC and long running actions

I have a controller action that aggregates data from multiple sources: web service, database, file lookups, etc... and passes results to the view. So in order to render the page all tasks must have completed. Currently they are performed sequentially but as they are independent I am thinking of running them in parallel as this could impr...

.Net: Logical thread and Thread Local Storage?

Hi I'm reading about the CallContext class (http://msdn.microsoft.com/en-us/library/system.runtime.remoting.messaging.callcontext.aspx). The documentation says something about "logical threads" and "Thread Local Storage". What's a logical thread, I didn't know that there existed multiple kinds of threads? What's a Thread Local Storag...

SwingWorker cancellation with ThreadPoolExecutor

Hi, i am using a ThreadPoolExecutor with a thread pool size of one to sequentially execute swing workers. I got a special case where an event arrives that creates a swing worker that does some client-server communication and after that updates the ui (in the done() method). This works fine when the user fires (clicks on an item) some ev...

Execution order with threads and PyGTK on Windows

I'm having issues with threads and PyGTK on Windows. According the the PyGTK FAQ (and my own experimentation), the only way to reliably update the GUI from a child thread is to use the gobject.idle_add function. However, it can't be guaranteed when this function will be called. How can I guarantee that the line following the gobject.i...

Win32 Read/Write Lock Using Only Critical Sections

I have to implement a read/write lock in C++ using the Win32 api as part of a project at work. All of the existing solutions use kernel objects (semaphores and mutexes) that require a context switch during execution. This is far too slow for my application. I would like implement one using only critical sections, if possible. The loc...

Can assignment be done before constructor is called?

A comment to http://stackoverflow.com/questions/945232/whats-wrong-with-this-fix-for-double-checked-locking says: The issue is that the variable may be assigned before the constructor is run (or completes), not before the object is allocated. Let us consider code: A *a; void Test() { a = new A; } To allow for more for...

What value is the ThreadState Property?

This question got me thinking about the .NET equivalent. What value is there to the ThreadState property of the Thread class? In this code example: if (someThread.ThreadState != System.Threading.ThreadState.Running) { someThread = new Thread(SomeMethod); someThread.Start(); } The someThr...

can you use multiple threads to ptrace an application?

I am writing a GUI oriented debugger which targets Linux primarily, but I plan ports to other OSes in the future. Because the GUI must stay interactive at all times, I have a few threads handling different things. Primarily I have a "debug event" thread which simply loops waiting for waitpid to return and delivers the received events to...