multithreading

Using exceptions within a boost::thread thread

Hello, I began to play around with boost::threads, but I'm kind of stuck with this problem: I don't understand why this program crashes as soon as the exception is thrown, because I try to catch it within the thread. I thought that it would be possible to work with exceptions as long as the handling happens in the same thread as the t...

Shared resource management in multithreaded application shared_ptr?

I have to share a BLOB in a multithreaded application and and I'm currently looking into shared_ptr/weak_ptr approach, but I'm not exactly sure it is correct. There is a worker thread that creates a resource class (new CResource). CResource can be quite large, so I want to avoid extra copies. Then there is another UI thread, I want to ...

Providing concurrent read and write access to objects through WCF

I have a .NET 4 WCF service that maintains a thread-safe, in-memory, dictionary cache of objects (SynchronizedObject). I want to provide safe, concurrent access to read and modify both the collection and the objects in the collection. Safely modifying the objects and the cache can be accomplished with reader-writer locks. I am running...

How to "multithread" C code

Hi, I have a number crunching application written in C. It is kind of a main loop that for each value calls, for increasing values of "i", a function that performs some calculations. I read about multithreading, and I am considering learning a bit about it, in C. I wonder if somehow general code like mine could be automatically multithr...

Segfault immediately after pthread creation

Hello all, I have a producer/consumer concurrency problem that I'm working on. The problem is that I'm getting a segfault thrown immediately after trying to create my first thread. Relevant code: customer is a struct declared as: struct pr2_customer { pthread_t customer_id; }; typedef struct pr2_customer customer; customers i...

Thread in Java/Android

Greetings. How can I send two parameters into a thread and run methods when the user pushes buttons on the display. Having my variables in the UI thread didn't work and were erased when the UI thread randomly restarts. UI Thread ______________ Other Thread User presses button -------> Run Method Cheers. ...

Why are locks needed in an instantiated class? Doesn't every instance have its own data etc?

In C#, a class level variable would not be thread-safe (any exceptions to this? Let me know). So I would have to wrap the usage of this variable (like in a method in the same class), in a lock. However, the very idea of using new makes me think that each class instance has its own instance etc and one instance variable is never shared, ...

Is the multi-threading model the real reason why OOP is falling and fP rising?

I been looking around at the problem of the multi-core chip stuff. would I be correct in assuming that the real problem with developing for mutlicore chips is nothing to do with the actual techniques of multi-tasking (isolated memory, task based etc), but more to do with the implementation of the threading model in the OS? I have been i...

Is java.util.Vector serialization thread-safe?

I know the Vector class is thread-safe for adding and removing elements [reference]. If I serialize a Vector using an ObjectOutputStream am I guaranteed a consistent (and non-corrupt) state when I deserialize it even if other threads are adding and removing objects during the seralization? ...

Any downsides to locking a collection vs. a syncRoot?

I'm wondering if there are any downsides to locking over a collection such as a List<T>, HashSet<T>, or a Dictionary<TKey, TValue> rather than a simple object. Note: in the following examples, that is the only place where the locks occur, it's not being locked from multiple places, but the static method may be called from multiple threa...

QThread, threaded, rly?

Hi for some time I am fiddly now to get a massive time/cputime drain action running behind a nicly responding UI. Unfortunatly I can't seem to get it running and "I think" the problem is that the slot is not processed in the QThread worker but the GUI thread. The ThreadIDs differ as expected though. I allready read this http://doc.trol...

Executing on a background thread using BeginInvoke

Hi Guys, I'm trying out multithreading but I cant figure out why the the piece of code below blocks the UI when task.Execute() is called? public class Task<TRes> { private Func<TRes> _func; public Task(Func<TRes> func) { _func = func; } public TRes Execute() { var iasync = _func.BeginInvoke(nul...

C# passing messages between classes

Hi, I'm a bit new to C# and multithread programming in general but here goes: I'm working on a system where I would have an class that would be instantiated and then wait for various messages from another running class. How should I go about catching and sending these messages? Thanks, PM ...

"Pythonic" multithreaded (Concurrent) language

Hi, I now primarily write in python, however I am looking for a language that is more thread friendly (not JAVA,C#,C or C++). Python's threads are good when they are IO bound but it's coming up short when I am doing something CPU intensive. Any ideas? Thanks, James ...

C# TcpClient not sending or reading 100% of data?

Hey all. I'm writing a simple client/server application (just for the experience, networking is fairly new to me) where the client sends the server data and the server outputs it to a textbox. It all works fine, except for one small detail... It seems sometimes a connection is made, but the data isn't being sent or read (can't work out w...

static members when used in synchronized method or block in java

Hi, when i use a synchronized method over instance method the monitor is associated with 'this' and on the other hand when i have synchronized on my class (static) method the monitor is associated with class object what in case if i have a static variable used in non static method? will that be synchronized? say public class A{ pub...

Must scenario for events related to Multithreading in C#?

I am wondering that in which scenario we must use events technique in multithreading and there is no other way around? I have seen cases we may use another syncronization techniques like Monitor wait and pulse to implement this. Can anyone help me out to understand events in Multithreading ? ...

Making WPF application multiprocess

I currently have a multithreaded application which runs in following order: Start up and change XML file Do work Change XML to default values The step 3 is very important and I have to insure that it always happens. But if the application crashes, I might end up with the wrong XML. The scenario where I am using it is: My applicati...

OpenMP : Is there a way for a thread to terminate all other parallel threads ?

I am experimenting with openMP for large data processing and relatively new to it. My input data set is huge and so I divided it into multiple subsets and each thread working on the subset of data. Each dataitem in the subset is acted up on by the thread. If one of the threads fails during its operation on any dataitem, i would like to t...

Multi-Threading WPF with Accessors

I am trying to update a UI element from a different thread but I am clearly missing something with regards to the new WPF calls. In 3.5 winforms I did something like the following when updating my UI via a different thread: public string SummaryTitle { get { if (IsHandleCreated && InvokeRequired) { IAsyncResult...