Is there a way to throw an exception when a user tries to use a non thread-safe method of a class in a multithreaded context? I guess the issue is mostly to detect that multiple threads are trying to use the method. Or, is there a "not_synchronous" keyword/tag I could ...
I hav following code: import java.io.*; import java.util.concurrent.* ; public class Example{ public static void main(String args[]) { try { FileOutputStream fos = new FileOutputStream("1.dat"); DataOutputStream dos = new DataOutputStream(fos); ...
Is there a systematic way to know whether an operation in C# will be atomic or not? Or are there any general guidelines or rules of thumb? ...
I am trying to create a script that allows me to send a GET request to every link in a text file at once. I am sure I could do this with threading but maybe you guys have a better suggestion. So far all it does is read each line ...
I have an app that takes on unknown amount of task. The task are blocking (they wait on network) i'll need multiple threads to keep busy. Is there an easy way for me to have a giant list of task and worker threads which will pull the task when they are ...
How can one in this simple example guarantee that the a->push_back(i) happens in the order in which the threads are started? So a contents would be {1,2,3}. #include <vector> #include <thread> void do_stuf(int i,std::vector<int> * a) { //do very long stuff a->push_back(i); } int main() { ...
I am new to multi-threading. I am using c++ on unix. In the code below, runSearch() takes a long time and I want to be able to kill the search as soon as "cancel == true". The function cancelSearch is called by another thread. What is the best way to solve ...
According to this online book, the volatile keyword in C# does not protect against reordering Write operations followed by Read operations. It gives this example in which both a and b can end up being set to 0, despite x and y being volatile: class IfYouThinkYouUnderstandVolatile { volatile ...
i have a program which i have a threading timer to update the time coming from the data server. However, i notice the timer run a few times and stop calling afterwards. i try and copy the threading timer code onto a new program and it runs fine, so i ...
So, that's what I'm trying to do - pretty self-explanatory actually : Initiate X 'simultaneous' processes (each bound to a different php script) Be able to say when all of them are finished I've had a look at various different approaches, and I'm probably going to use exec and background processes. (Something along ...
I have a problem that I cannot solve even after looking at the various information about Dispatcher.Invoke. There is a MainWindow that creates a task, starts that task and then opens a progress window. When the task completes, I need to close the progress window. Here's what I have: private void Button_Click(object ...
I have a mongodb with thousands of records holding very long vectors. I am looking for correlations between an input vector with my MDB data set using a certain algorithm. psudo code: function find_best_correlation(input_vector) max_correlation = 0 return_vector = [] foreach reference_vector in ...
I have a multi threaded program in which I sleep in one thread(Thread A) unconditionally for infinite time. When an event happens in another thread (Thread B), it wake up Thread-A by signaling. Now I know there are multiple ways to do it. When my program runs in windows environment, ...
I'm trying to run a look to update CPU Usage onto a progress bar from a thread. The code I have here is: private static int _cpuUsage; protected PerformanceCounter cpuCounter; private Thread thread; public CPUUsageIndModel() { cpuCounter ...
I have a producer thread that generates objects and puts it in a shared queue. I have spawned a bunch of consumer threads that can read from this queue. In an ideal situation every one of my workers will pick up the next job from the queue. But for some ...
I wrote a typical producer-consumer program: one producer, which is responsible for filling the queue; one consumer, which is responsible for dequeuing the queue. Below is my implementation. The tricky part is that there is another sharing variable vFlag. the process(str) may change its value to true, which will be ...
I am writing an Android app that connects to a Bluetooth device, reads data sent from the device, adds it to an AChartEngine graph, and displays the data in a TextView. My Bluetooth code is quite similar to the threaded implementation in the BluetoothChat sample code (it comes with ...
Have set up a storage adapter (Contextual) for help creating and managing a single database and table. Trying to access the table from a new thread for reading records and transmitting them via HTTP in the background. Other access to the database is activity based and insert only. Although the ...