Questions tagged "multithreading" (page No.1)

Prevent non thread-safe method to be used in multithreaded context

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 ...

Java Parallel File Proccessing

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); ...

What operations are atomic in C#?

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? ...

Sending a Request To Every URL At Once Python

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 ...

Easy way to have X threads with ??? task?

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 ...

Ordered multithreading output in c++

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() { ...

cancelling a search using threads

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 ...

Why doesn't C# volatile protect write-read reordering?

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 ...

threading timer not working, why?

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 ...

Executing multiple PHP scripts in parallel, and being notified when finished

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 ...

Close window from different thread in WPF using Dispatcher.Invoke

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 ...

mongodb map reduce on multicore server

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 ...

sleeping on an event

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, ...

Progress Bar Binding isn't updating from a thread

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 ...

Queue entry broadcasted to multiple threads

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 ...

How to avoid concurrency bugs when sharing variables between threads?

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 ...

Android UI thread stops updating from other threads

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 ...

Accessing sqllite db from a thread

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 ...

« Previous12345678910 ... 13421343Next »Show All