I've written background InputStream (and OutputStream) implementations that wrap other streams, and read ahead on a background thread, primarily allowing for decompression/compression to happen in different threads from the processing of the decompressed stream.
It's a fairly standard producer/consumer model.
This seems like an easy wa...
I have a counter variable which will be accessed by multiple threads which will increment/decrement it. It should not be updated by multiple threads at the same time.
I know that you can create a mutex object which has to be obtained before the variable in question can be changed. A critical section in this case is not appropriate becau...
Hi guys.
I have a java program, with multi threading. My problem is that from time to time, I have a timeout.
Because I have some unix stuff I cannot see where is the timeout or/and lock. The problem is that this does not happens every night, only from time to time.
Actually, an unix component (lsf) kill the thread (if timeout more that...
Hello
i´m creating a thread that takes as parameter dispatchInputs which is an CString array
but in mean while i need to use "env" in DispFrontEnd function, can a thread use the global variable "env" ? if not how how can i pass it as argument to DispFrontEnd ?
static JNIEnv *env;
static JavaVM *jvm;
JNIEnv* startJVM()
{
JNIEnv *en...
In my destructor I want to destroy a thread cleanly.
My goal is to wait for a thread to finish executing and THEN destroy the thread.
The only thing I found about querying the state of a pthread is pthread_attr_setdetachstate but this only tells you if your thread is:
PTHREAD_CREATE_DETACHED
PTHREAD_CREATE_JOINABLE
Both of those h...
Is there a GUI for GDB that will allow me to debug applications that create threads using clone() syscall? I tried Insight and KDBG, but for some reason when the new cloned thread is created, I can't see it in the thread list. The clone syscall is called through inline assembly. Is it not possible because the thread created shares PID wi...
I'm looking at this bit of text in the documentation for Visual C++'s _ReadWriteBarrier intrinsic:
In past versions of the Visual C++
compiler, the _ReadWriteBarrier and
_WriteBarrier functions were enforced only locally and did not affect
functions up the call tree. In Visual
C++ 2005 and later, these functions
are enforce...
I've got a small class (16 bytes on a 32bit system) which I need to dynamically allocate. In most cases the life-time of any given instance is very short. Some instances may also be passed across thread boundaries.
Having done some profiling, I found that my program appears to be spending more time allocating and deallocating the things...
I'm learning Multi Threading at the moment, in C#, but as with all learning I like to learn best practices. At the moment the area seems fuzzy. I understand the basics, and I can create threads.
What should I look out for when creating multi threaded applications. Are there any set rules or best practices that I should know about? Or an...
Hey - I'm having an odd problem with a little toy program I've written, to try out threads.
This is my code:
#include <pthread.h>
#include <iostream>
using std::cout;
using std::endl;
void *threadFunc(void *arg) {
cout << "I am a thread. Hear me roar." << endl;
pthread_exit(NULL);
}
int main() {
cout << "Hello there." <<...
I like the ExecutorService series of classes/interfaces. I don't have to worry about threads; I take in an ExecutorService instance and use it to schedule tasks, and if I want to use an 8-thread or 16-thread pool, well, great, I don't have to worry about that at all, it just happens depending on how the ExecutorService is setup. Hurray!
...
I'm creating a WPF application using the Composite Application Library (CAL), aka PRISM. I'm also using MVVM (Model-View-ViewModel). To prevent background processing from blocking the UI and making it unresponsive, I want to have the view model make most work calls on a background thread. To do this, I'm using the .NET ThreadPool object...
Say I have two usercontrols, UC1 and UC2. A user selects something in UC1, which takes some time so the process is threaded off. UC2 needs to update its view and do some work of its own on another thread when UC1 finishes. But UC2 is dependent on the output of the UC1 background thread so it has to wait until that thread is finished b...
I've been reading Joe Duffy's book on Concurrent programming. I have kind of an academic question about lockless threading.
First: I know that lockless threading is fraught with peril (if you don't believe me, read the sections in the book about memory model)
Nevertheless, I have a question:
suppose I have an class with an int proper...
I recently stumbled upon this Wikipedia article. From my experience with multi-threading I am aware of the multitude of issues caused by the program being able to switch threads between threads at any time. However, I never knew that compiler and hardware optimisations could reorder operations in a way that is guaranteed to work for a si...
I've found the "ThreadStatic" attribute to be extremely useful recently, but makes me now want a "ThreadLocal" type attribute that lets me have non-static data members on a per-thread basis.
Now I'm aware that this would have some non-trivial implications, but:
Does such a thing exist already built into C#/.net? or since it appears so...
I am working with a framework that runs its own event dispatcher in a separate thread. The framework may generate some events.
class SomeDataSource {
public event OnFrameworkEvent;
void FrameworkCallback() {
// This function runs on framework's thread.
if (OnFrameworkEvent != null)
OnFrameworkEven...
If have come across an anomaly where it seems that some machines that have not had a Windows Update applied to them in a VERY long time that the .NET Framework 2.0 didn't have a specific overload available in it.
AutoResetEvent.WaitOne(int32) appears to be non existant under an early revision. According to MS documentation this method h...
I'm thinking of using boost::weak_ptr to implement a pool of objects such that they will get reaped when nobody is using one of the objects. My concern, though, is that it's a multi-threaded environment, and it seems there's a race condition between the last shared_ptr to an object going out of scope and a new shared_ptr being construct...
Hi,
I want to study some good multi-threaded Java code. Could anyone please suggest some examples ? Is Apache web server a good pick ?
Thanks,
Abhinav.
...