multithreading

Android : background thread

Team, I need to run a background thread in my application. Could you please share the best practices where to initiate the thread so that keeps running irrespective of the Activity is being shown and things to consider. The purpose of this background thread is to fire transactions from the Simulator to the server and get the response b...

Basic tutorial for multithreading

Hi, I'm a coding newbie, but I really wanna learn how to do multithreading and event handling. Does anyone know of any good tutorials out there, or can they explain it to me in a nutshell? ...

Parallel processing via multithreading in Java

There are certain algorithms whose running time can decrease significantly when one divides up a task and gets each part done in parallel. One of these algorithms is merge sort, where a list is divided into infinitesimally smaller parts and then recombined in a sorted order. I decided to do an experiment to test whether or not I could I ...

Why do debug symbols so adversely affect the performance of threaded applications on Linux?

Hi. I'm writing a ray tracer. Recently, I added threading to the program to exploit the additional cores on my i5 Quad Core. In a weird turn of events the debug version of the application is now running slower, but the optimized build is running faster than before I added threading. I'm passing the "-g -pg" flags to gcc for the debug...

How to check whether the form has any ShowDialog() forms open?

I have a form MainForm with several properties/methods that are accessed from another thread. At some point I might open a form AuxForm with ShowDialog() and then while that modal form is open, the other thread still modifies the MainForm's properties. This is all desired. In one of the methods accessed from another thread I need to ...

Is F# a poor choice for a functional language

Hi, To me, I think F# is a bad choice due to the fact that it uses threads behind the scenes. To me, threads are too "heavy" due to things like context switching. I can see why Erlang is a good choice because it uses light weight processes. Am I wrong? Cheers Paul ...

"Win32 exception occurred releasing IUnknown at..." error using Pylons and WMI

Hi all, Im using Pylons in combination with WMI module to do some basic system monitoring of a couple of machines, for POSIX based systems everything is simple - for Windows - not so much. Doing a request to the Pylons server to get current CPU, however it's not working well, or atleast with the WMI module. First i simply did (somethin...

How to find where program crashed

I have a program that crashes (attempting to read a bad memory address) while running the "release" version but does not report any problems while running the "debug" version in the visual studio debugger. When the program crashes the OS asks if I'd like to open up the debugger, and if I say yes then I see an arrow pointing to where I a...

Reading a variable messes it up?!?!

We have the following line of code: printf("%d\n", toc->runlist.next); printf("%d\n", toc->runlist.next); These are the definitions: typedef struct thread_overview_control{ int id[NR_UTHREADS]; list_t runlist; int active_counter; int main_thread; int need_resched; } thread_overview_control; thread_overview_cont...

iphone singleton object synchronization

I'm working on an iphone app but this is probably a general question. I have a singleton Model class and there would be scenarios where multiple NSOperations (threads) would exist and work with the singleton object. If they all call the same method in this object, do i need to have some locking mechanism? Or can this method be executed...

boost scoped_lock mutex crashes

hello, I have protected a std::queue's access functions, push, pop, size, with boost::mutexes and boost::mutex::scoped_lock in these functions from time to time it crashes in a scoped lock the call stack is this: 0 0x0040f005 boost::detail::win32::interlocked_bit_test_and_set include/boost/thread/win32/thread_primitives.hpp 361 1...

Java: thread-safe RandomAccessFile

Hi, After some serious googleing I found out that the RandomAccessFile-class is not thread-safe. Now I could use one semaphore to lock all reads and writes but I don't think that performs very well. In theory it should be possible to do multiple reads and one write at a time. How can I do this in Java? Is it possible at all? Thanks! ...

How to log correct context with Threadpool threads using log4net?

I am trying to find a way to log useful context from a bunch of threads. The problem is that a lot of code is dealt with on Events that are arriving via threadpool threads (as far as I can tell) so their names are not in relation to any context. The problem can be demonstrated with the following code: class Program { private static ...

cache-coherence MOESI protocol

processor A owns a cache line which is shared with processor B. what happens when B tries to write to that line? also, if it was 'invalid' instead of 'shared' would it make any difference? thank you. ...

Background thread in .NET

When the user saves some data, I want to spin off a background thread to update my indexes and do some other random stuff. Even if there is an error in this indexing the user can't do anything about it, so there is no point in forcing the main thread to wait until the background thread finishes. I'm doing this from a ASP.NET process, so ...

Java: Using multiple Threads to paint simultaniously on a JPanel

I have a JPanel on which I wish to have several threads painting "animations" on. An "animation" consists of a JLabel with an ImageIcon on it, which is being moved from one area of the screen to another area. Now, problem is - I want several such animations to be portrayed on screen by those threads mentioned. Problem is - the JPanel's...

How can I get synchronous/blocking I/O in ruby across multiple threads?

I simply want to use ruby, yet I feel that I cannot if my goal includes using multiple threads that do any form of blocking IO. Even for what would be a small script, when I see the need for multiple threads I start to turn to java. Is there a good way I can use Ruby to create multiple threads, have each block when needed? As many of you...

Is multithreading the right way to go for my case?

Hello, I'm currently designing a multi-client / server application. I'm using plain good old sockets because WCF or similar technology is not what I need. Let me explain: it isn't the classical case of a client simply calling a service; all clients can 'interact' with each other by sending a packet to the server, which will then do some...

Will creating a background thread in a WCF service during a call, take up a thread in the ASP .NET thread pool?

The following code is part of a WCF service. Will eventWatcher take up a thread in the ASP .NET thread pool, even if it is set IsBackground = true? /// <summary> /// Provides methods to work with the PhoneSystem web services SDK. /// This is a singleton since we need to keep track of what lines (extensions) are open. /// </summary> publ...

Thread vs async execution. What's different?

I believed any kind of asynchronous execution makes a thread in invisible area. But if so, Async codes does not offer any performance gain than threaded codes. But I can't understand why so many developers are making many features async form. Could you explain about difference and cost of them? ...