multithreading

what would make a single task executor stop processing tasks?

I'm using a java.util.concurrent.ExecutorService that I obtained by calling Executors.newSingleThreadExecutor(). This ExecutorService can sometimes stop processing tasks, even though it has not been shutdown and continues to accept new tasks without throwing exceptions. Eventually, it builds up enough of a queue that my app shuts down wi...

How to find the beginning and end of thread local storage?

How, under Windows and Linux, given a thread handle can I determine the beginning and end of its corresponding static thread local storage block? ...

Is there any sample code to do iPhone mulitithreading tasks?

I have some slow internet task to save and load file, I'd like to do those slow tasks in some background thread. I am wondering whether that's doable, and if it is, any sample code? Then after it is finished, I'd like it to notice back to the main thread, so that I could update the UI. Thanks in advance. // Jack ...

Firing a mainline event from a background thread in Java

Hiya, My question pertains to multi-threading in Java. I'm translating an app I wrote in Visual Basic 2008 into Java. There is a class in VB called BackgroundWorker, which allows the coder to perform a task on another thread, a lot like SwingWorker in Java. The only distinct difference is that, with the BackgroundWorker thread is run(),...

Best threading queue example / best practice

I have data that needs to be executed on a certain background thread. I have code coming from all other threads that need to call into this. does anyone have a good tutorial or best practice on having a queue for synchronization to support this threading requirement ...

Why does the inner exception reach the ThreadException handler and not the actual thrown exception?

I'm seeing some wierd behaviour when throwing exceptions and catching them in the Application.ThreadException event handler. Basically whats happening in the sample below is that an exception is thrown in the DoWork event handler of a BackgroundWorker. The RunWorkerCompleted event handler rethrows a new exception with the original as th...

Running portions of a loop in parallel with Octave?

I have the following code that I need to run over a matrix with over 20000 rows. It takes several minutes to run and the datenum and str2double functions appear to be the bottlenecks. Since no calculation depends on previous ones is there a way to break the loop into multiple parts and have them execute in parallel? Any advice on optimis...

Multiple Dispatchers problem

I have the following problem: Multithreaded WPF application, Model View Presenter Implementation. Presenters and Views that belong together are created by a factory on a separate thread and should get a separate Dispatcher. Public Function CreatePresenter(Of T As {New, Class})(ByVal p_eCreationOptions As eViewCreationOptions) As T Impl...

OS X inter thread communication question

I am developing a multi-threaded application in Cocoa. The main thread takes values from the user, and when a button is clicked I invoke a secondary thread in which a long calculation takes place. Now from this thread I have to return the output of every step of the calculation to the main thread. I want to periodically send data from on...

Experiences with SEDA and C#?

I'm thinking about SEDA. We design at the moment an application (which is running on a server as a service) which must be multithreaded and message / event based. The SEDA idea is very intresting and should match. But I cannot find articles etc. writing about experiences made with it. My question(s) now is(are): Do you use ActiveMQ...

Use of volatile (Thread.VolatileRead/ Thread.VolatileWrite) in C#

In a multi-threaded program running on a multi-cpu machine do I need to access shared state ( _data in the example code below) using volatile read/writes to ensure correctness. In other words, can heap objects be cached on the cpu? Using the example below and assuming multi-threads will access the GetValue and Add methods, I need Threa...

Using Parallel.For to test SQL queries and comparison with the ThreadPool

I'm looking for a way to easily load test and benchmark some of our SQL (using ADO.NET, nothing fancy using LINQ or PLINQ) that has to be performant when running under high parallel load. I've thought of using the new parallel extensions CTP and specifically Parallel.For / Parallel.ForEach to simply run the SQL over 10k iterations or so...

Threading issue (chase your own tail)

There is ConnectionManager which waits for incoming connections. For each incoming connection it creates a Connection instance which handles the inbound and outbound traffic on this connection. Each Connection has a Watchdog which handles "bad connection" conditions and calls registered "Listerners". One "Listener" is the ConnectionManag...

ObservableCollection<T> not updating UI

I'm having an issue with an ObservableCollection getting new items but not reflecting those changes in a ListView. I have enough quirks in the way I'm implementing this that I'm having a hard time determining what the problem is. My ObservableCollection is implemented thusly: public class MessageList : ObservableCollection<LobbyMessag...

C#/Winform: Enter data into HTML page, submit form

I have a Winform with a BackgroundWorker. The BackgroundWorker, among other things, has to make an HTTP call to a page, fill out some data, submit the form, and retrieve the HTML that comes back after "clicking" the submit button. I've run into a number of roadblocks while doing this: Can't POST the data because the target webserver do...

Timing out tests in TestNG

Thanks to a library upgrade (easymock 2.2 -> 2.4), we're having tests that have started locking up. I'd like to have a time out on individual tests, all of them. The idea is to identify the locked up tests - we're currently guessing - and fix them. Is this possible, preferably on a suite-wide level? We have 400 tests, doing this each me...

running code with threads in Octave

I have several blocks of the following code that each use there own matrix. Is there a way to run each block in it's own thread rather then run all of them sequentially? for i=1:length(DJI) DJI2(:,1) = reshape(datenum(strvcat(DJI(:,2)(:)), length(DJI(:,2)),'yyyy-mm-dd')); DJI2(:,2:6) = reshape(str2num(strvcat(DJI(:,3:7)(:)), length(DJI...

Code Re-entrancy vs. Thread Safety

What is the difference between the concepts of "Code Re-entrancy" and "Thread Safety"? As per the link mentioned below, a piece of code can be either of them, both of them or neither of them. Reentrant and Thread safe code I was not able to understand the explaination clearly. Help would be appreciated. ...

Delphi Win API CreateTimerQueueTimer threads and thread safe FormatDateTime crashes

Hi This is a bit of a long question, but here we go. There is a version of FormatDateTime that is said to be thread safe in that you use GetLocaleFormatSettings(3081, FormatSettings); to get a value and then you can use it like so; FormatDateTime('yyyy', 0, FormatSettings); Now imagine two timers, one using TTimer (interval say ...

how to make a thread wait until a file is created in java

Hi All, i have a thread in java & i need this thread to wait until a file is exist or created. i write the following code: while(!receivedDataFile.isFileExists("receiveddata.txt")) { try { Thead.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStac...