multithreading

Threads hierarchy design in kernel in CUDA

Assuming a block has limit of 512 threads, say my kernel needs more than 512 threads for execution, how should one design the thread hierarchy for optimal performance? (case 1) 1st block - 512 threads 2nd block - remaining threads (case 2) distribute equal number of threads across certain blocks. ...

how to update a windows form GUI from another class?

Hi, how do you update a win forms control (ex. label, progress bar) from another class which created the GUI but not in the creating thread? (for example, an event handler of Program.cs) I've found several posts regarding updating GUI from another thread using Invoke() method, but what i've found so far only works if the codes are writt...

Non blocking wait in python

Hi, in python, if i want to keep a process or thread running forever, i can typically do this with an empty while loop: while 1: pass this, however, will eat an unfair amount of CPU process. Adding a short sleep would work import time while 1: time.sleep(0.01) Is there any best and cleaner way of doing this? Thanks ...

Using of threads to update labels after receiving string from bluetooth.

Hi all i have a thread that is able to read data being received across from bluetooth stream. On the sender part i made it a while loop where count keeps on increasing + 1. I did a messagebox.show(test); and it works fine but when i do a label.text = test i get : "Control.Invoke must be used to interact with controls created on a separa...

ArcGIS Explorer: Invoke main thread from secondary thread

I'm developing a small add-in for ESRI ArcGIS Explorer 1200. The extension itself is quite simple, it just uses a FileSystemWatcher to wait for an incoming file, then processes the file. My main problem is: When the FileSystemWatcher event fires, it uses a different thread than the GUI-thread. So I can't access GUI-related objects. Now ...

How to give name to a callable Thread?

Hi Guys, I am executing a Callable Object using ExecutorService thread pool. I want to give a name to this thread. To be more specific, in older version I did this - Thread thread = new Thread(runnable Task); thread.setName("My Thread Name"); I use thread name in log4j logging, this helps a lot while troubleshooting. Now I am migrat...

Maintaining Order in a Multi-Threaded Pipeline

I'm considering a multi-threaded architecture for a processing pipeline. My main processing module has an input queue, from which it receives data packets. It then performs transformations on these packets (decryption, etc.) and places them into an output queue. The threading comes in where many input packets can have their contents...

Start and Stop Thread from WebApp

Hi, I write to understand if and how I could do the following thing. I have a WebApp for management, in which I should add a button (or something similar) to start and stop a Java thread (this thread polls on DB, send email and so on). The aim is to enable users to manage the life of this thread, deciding whether to keep it alive for a ...

Pause/Resume thread whith AutoResetEvent

In this code I want to Pause/Resume a thread using an AutoResetEvent and a bool variable. Is is possible to Pause whithout testing each time (in for loop of Work()) if blocked==true? Testing of "blocked" variable needs locking also and i think this is time consuming. class MyClass { AutoResetEvent wait_handle = new AutoReset...

Suggest an Improved approach for Multi-threaded application

Hello there, I am building up a multi-threaded application where I spawn three threads when application starts and these threads continue to run for application lifetime. All my threads are exclusive and do not interfere with each other in anyway. Now a user can suspend the application and, here I want to suspend or, say, abort my threa...

C# BackgroundWorker Cancellation with Helper Function

Normally, when I want to cancel a backgroundWorker in C# I will do something like this: while (backgroundWorker1.IsBusy) { backgroundWorker1.CancelAsync(); autoResetEvent1.WaitOne(BGW_CANCEL_TIMEOUT); } In one application there are a number of backgroundWorkers. Is it valid to use a helper-function to c...

С++ how to delete object created in another thread

There is a long-time request and is called from the "main" (UI) thread. It is planned to move it's call into a separate thread. The problem is that some objects are created in this thread on the heap (main thread will have to work with these pointers). Questions: Is it allowed to delete 'another-thread' objects in the main thread? Is ...

c++ unused memory of objects containing only pointers , how to free?

I've just written some threaded code which handles huge objects. Even when I clean up everything from an object (without deleting it), it keep eating GBs of RAM. FYI, I reproduced the issue in a smaller environment. This code creates a structure and an object containing a vector of pointers to the structure. Then I fill the object with ...

Efficient Independent Synchronized Blocks?

I have a scenario where, at certain points in my program, a thread needs to update several shared data structures. Each data structure can be safely updated in parallel with any other data structure, but each data structure can only be updated by one thread at a time. The simple, naive way I've expressed this in my code is: synchroniz...

How can i get the instance of a BackgroundWorker from the currently executed method?

I am using a backgroundworker that can have n instances. Problem is the DoWork method (that has the 'sender' parameter which is the BackgroundWorker) calls other code that produces a callback - thus i dont have the sender. How can i determine the BackgroundWorker that the current code is running under? ex: private void SetupThread(...

Android -- SQLite + SharedPreferences, 2 Threads Simultaneous Read/Write?

Hello, I have two parts of a program (the actual app and a BroadcastReceiver) that could possibly try to connect to and modify a SQLite database and a SharedPreferences file. 1) I know you can make multiple connections to a single SQLite database. I also read that SQLite can "lock" the database when it attempts to modify or read from a...

WinAPI Write "Edit" Dialog to Pipe (Error: Stack around variable 'x' was corrupted)

Hello everyone. It seems I figured out most of my problems by simply multi-threading my application! However, I am running into a little bit of an error: "Stack around variable 'x' was corrupted." It works properly (after hitting abort on the Debug Error), but obviously I cannot have an error everytime someone runs the application. So he...

why is the threadID the same when i run my app with different browsers simultaneously?

I have a simple application that contains one button to be clicked in order to start logging, and basically I log messages to database. The application is already set up to log messages to a database. So, I tried to run my application in my machine but with two different browsers, for example( google chrome and Internet Explorer) at the ...

C++ Sockets Send() Thread-Safety

I am coding sockets server for 1000 clients maxmimum, the server is about my game, i'm using non-blocking sockets and about 10 threads that receive data simultaneously from different sockets (first thread receives from 0-100,second from 101-200 and so on..) but if thread 1 wants to send data to all 1000 clients and thread 2 also wants t...

synchronized section does not block!

I've noticed something very strange yesterday. It seems that two threads are entering two synchronized blocks locking on the same object at the same time. The class (MyClass) containing the relevant code looks similar to this: private static int[] myLock = new int[0]; protected static int methodA(final long handle, final byte[] so...