multithreading

Win32 threads synchronization/performance monitoring tools

would Intel(R) VTune(TM) Thread profiler be able to tell if threads synchronization was successful? I'm never profiled any application, where do i start? ...

NSOperation Causing Crash when Passed to Delegate

For an iPhone app, I'm using a NSOperationQueue to limit access to the SQLite database to one query at a time. I created a subclass of NSOperation and in the main function I have the following: - (void)main { // ... other code here ... if( [_delegate respondsToSelector:@selector(queryCompleted:)] ) { [_delegate ...

Message queue proxy in Python + Twisted

Hi, I want to implement a lightweight Message Queue proxy. It's job is to receive messages from a web application (PHP) and send them to the Message Queue server asynchronously. The reason for this proxy is that the MQ isn't always avaliable and is sometimes lagging, or even down, but I want to make sure the messages are delivered, and ...

ConcurrenctBag(Of MyType) Vs List(Of MyType)

What is the advantage of using a ConcurrentBag(Of MyType) against just using a List(Of MyType)? The MSDN page on the CB (http://msdn.microsoft.com/en-us/library/dd381779(v=VS.100).aspx) states that ConcurrentBag(Of T) is a thread-safe bag implementation, optimized for scenarios where the same thread will be both producing and ...

Can multiple threads access a vector at different places?

Lets say I have a vector of int which I've prefilled with 100 elements with a value of 0. Then I create 2 threads and tell the first thread to fill elements 0 to 49 with numbers, then tell thread 2 to fill elements 50 to 99 with numbers. Can this be done? Otherwise, what's the best way of achieving this? Thanks ...

How to find CPU-intensive class in Java?

I have a big program in Java that uses multithreading. In some cases, the program starts using 100% of three cores of my eight core system. In normal use, the program use all cores at 1-2%. How can I find the class that's overloading cores? ...

unprotected access to member in property get

I have a property public ObservableCollection<string> Name { get { return _nameCache; } } _nameCache is updated by multiple threads in other class methods. The updates are guarded by a lock. The question is: should I use the same lock around my return statement? Will not using a lock lea...

Is it safe to make GL calls with multiple threads?

I was wondering if it was safe to make GL calls with multiple threads. Basically I'm using a GLUtesselator and was wondering if I could divide the objects to draw into 4 and assign a thread to each one. I'm just wondering if this would cause trouble since the tesselator uses callback functions. Can 2 threads run the same callback at th...

C++0x error : variable 'std::packaged_task<int> pt1' has initializer but incomplete type

Hi All, Below is a simple program in c++0x that makes use of packaged_task and futures. while compiling the program i get error : variable 'std::packaged_task pt1' has initializer but incomplete type the program is below #include <future> #include <iostream> using namespace std; int printFn() { for(int i = 0; i < 100; i++) ...

Help with java threads or executors: Executing several MySQL selects, inserts and updates simmultaneously

Hi. I'm writing an application to analyse a MySQL database, and I need to execute several DMLs simmultaneously; for example: // In ResultSet rsA: Select * from A; rsA.beforeFirst(); while (rsA.next()) { id = rsA.getInt("id"); // Retrieve data from table B: Select * from B where B.Id=" + id; // Crunch some numbers using the dat...

C# Multi threading- Move objects between threads

Hi, i am working with a winforms control that is both a GUI element and also does some internal processing that has not been exposed to the developer. When this component is instantiated it may take between 5 and 15 seconds to become ready so what i want to do is put it on another thread and when its done bring it back to the gui thread ...

Reason for .Net UI Element Thread-restriction

We know that it is not possible to execute code that manipulates the properties of any UI element from any thread other than the thread the element was instantiated on... My question is why? I remember that when we used COM user interface elements, (in COM/VB6 days), that all UI elements were created using COM classes and co-classes...

Thread Proc for an instancable class?

Basically I have a class and it is instincable (not static). Basically I want the class to be able to generate its own threads and manage its own stuff. I don't want to make a global callback for each instance I make, this doesnt seem clean and proper to me. What is the proper way of doing what I want. If I try to pass the threadproc to ...

Works on debug but not release

I have a thread that sets a value to true when it is done. Until then I wait: while(1) { if(done[0] == true) { break; } } This code works just fine in Debug but in Release it stays in the loop forever even though the debugger clearly says that it is true and not false. Why would this not work? Thanks ...

Critical section initialization when creating thread-safe singleton (C++)

I'm trying to do the same thing as suggested in this solution: http://stackoverflow.com/questions/164496/how-can-i-create-a-thread-safe-singleton-pattern-in-windows/164640#164640 But, where should the critical section be initialized and uninitialized? ...

How to address thread-safety of service data used for maintaining static local variables in C++?

Consider the following scenario. We have a C++ function with a static local variable: void function() { static int variable = obtain(); //blahblablah } the function needs to be called from multiple threads concurrently, so we add a critical section to avoid concurrent access to the static local: void functionThreadSafe() { ...

Thread-safe initialization of function-local static const objects

This question made me question a practice I had been following for years. For thread-safe initialization of function-local static const objects I protect the actual construction of the object, but not the initialization of the function-local reference referring to it. Something like this: namspace { const some_type& create_const_th...

When I really need to use [NSThread sleepForTimeInterval:1];

Hi there, I have a program that needs to use sleep. Like really needs to. In lieu of spending ages explaining why, suffice to say that it needs it. Now I'm told to split off my code into a separate thread if it requires sleep so I don't lose interface responsiveness, so I've started learning how to use NSThread. I've created a brand...

Difference between Thread.Sleep(0) and Thread.Yield()

As Java has had Sleep and Yield from long ago, I've found answers for that platform, but not for .Net .Net 4 includes the new Thread.Yield() static method. Previously the common way to hand over the CPU to other process was Thread.Sleep(0). Apart from Thread.Yield() returning a boolean, are there other performance, OS internals differe...

Make 2 functions run at the same time.

Hi, I am trying to make 2 functions run at the same time. def func1(): print 'Working' def func2(): print 'Working' func1() func2() Does anyone know how to do this? ...