multithreading

Thread.Join vs Thread.State

Hi, Thread.Join returns us if the thread has completed. The same we can determine using ThreadState. Then what is the difference between Thread.Join() and Thread.ThreadState? Can we use them interchangeably? ...

Calling a webservice async

Long post.. sorry I've been reading up on this and tried back and forth with different solutions for a couple of days now but I can't find the most obvious choice for my predicament. About my situation; I am presenting to the user a page that will contain a couple of different repeaters showing some info based on the result from a coup...

Is 'volatile' needed in this multi-threaded C++ code?

Hello, I've written a Windows program in C++ which at times uses two threads: one background thread for performing time-consuming work; and another thread for managing the graphical interface. This way the program is still responsive to the user, which is needed to be able to abort a certain operation. The threads communicate via a shar...

Android: How to send back data from thread to service?

Hy! I have a service from which a start a new thread. This new thread will communicate with a TCP server using socket. What is the best way to send the data received from TCP server back to the service? Handlers or something else? Thanks in advance, kukukk ...

Is it Ok to use a Thread for each Animation in a Java program?

I am working on a Java program which contains a lot of animations as part of the UI. Each animation requires a repaint method to be called in order to make the animation happen. I was just wondering if it was good programing to use a separate thread for each animation, which would each call their respective repaint methods. ...

how to support many sql queries on a web at the same time?

The question is: if I have a webpage hosted somewhere. The backend environment is LAMP supported. For example: whenever a user opens a new page, it will create a new mysql connection to the MySQL database server and do a corresponding query. We all know that MySQL has a max_connection limit (100 for version <5.1 as default). Of course...

Pass an actual command as argument Java

Hello, I'm currently using a separate thread in Java that could potentially be used for a lot of different functionality, and I'm wondering if there is a way to pass the command for an actual function call as a parameter. This would look something along the lines of: class myWorkerThread implements Runnable { private (<String/what...

How to join threads in Objective C without using delegates/callback?

Is there a clean way of joining threads in Objective C much like "Thread.join" in Java? I found the method performSelector:onThread:withObject:waitUntilDone: but the limitation of this is I can't call the "blocking" on a different line because I want to do something like this: [dispatch Thread A]; [process something on main thread]; [w...

Threading using isReachable() on XP for subnet ping

Hi, I have written an app that should ping (use isReachable) for all the clients on the subnet the host sits on but I'm getting strange results when it is run on an XP machine (SP2) it fails to get all the hosts. It appears to be linked to threading as if I put in a join and effectively force the app to use one thread it works. It works...

Javascript: Execute and Quine at the same time

I have a bizarre need here, and I am unsure of it's feasibility. I can only think how I would do it using threads (To create another thread that performs a Quine function along side a thread running the script I want to Quine and execute at the same time (without manually adding alerts everywhere!!!), but javascript doesn't have that fun...

Release a lock temporarily if it is held, in python

I have a bunch of different methods that are not supposed to run concurrently, so I use a single lock to synchronize them. Looks something like this: selected_method = choose_method() with lock: selected_method() In some of these methods, I sometimes call a helper function that does some slow network IO. (Let's call that one netw...

Need help with Backgroundworker

Hi, Need help on how to use .Net's Backgroundworker thread for the following purpose to increase UI responsiveness and performance in my .Net winforms application.Since am new to .Net/C#, any code would be helpful. When user clicks "Calculate" button in UI form, 1.Get a list of categories C from database[this is typically around 10] ...

Need help on Backgroundworker

*Note:Rephrasing my question based on user's comments. Need help on how to use .Net's Backgroundworker thread for the following purpose to increase UI responsiveness and performance in my .Net winforms application. When user clicks "Calculate" button in UI form,I'm doing this: 1.Get a list of categories C from database[this is typicall...

How do you mark a Ruby Binding as trusted?

From this article http://www.stuartellis.eu/articles/erb referring to thread safety levels: "At this level, the specified binding must be marked as trusted for ERB to use it." I've searched high and low and haven't found a way to "mark" a Binding as "trusted". Will somebody please enlighten me? ...

How to know if a Python multiprocessing.Lock is released or not?

>>> l = Lock() >>> l.acquire() True >>> l.release() >>> l.release() Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: semaphore or lock released too many times throws a ValueError exception. How can I prevent to release a lock more than once? Something like l.is_released() ? ...

Can multiple WebClient interfere with each other?

I must build a Application that will use Webclient multiple times to retrieve every "t" seconds information from a server. Here is a small plan to show you what I'm doing in my application: Connect to the Web Client "USER_LOGIN" that returns me a GUID(user unique ID). I save it and keep it to use it in future Web Client calls. Connect...

Who stops my threads?

I have some threads fishing into a queue for jobs, something like this: class Worker(Thread): [...] def run(self): while not self.terminated: job = myQueue.get_nowait() job.dosomething() sleep(0.5) Now, self.terminated is just a bool value I use to exit the loop but, this is the prob...

Deadlocked when allocating an std::string

Hi, I have an application with several threads running. I have 2 threads that seem deadlocked when trying to allocate an std::string. Inspecting the backtrace of both threads suggest that at some point one has tried to allocate an std::string, and got a bad_alloc exception. In its catch block, another string is created in an attempt to ...

How to set Priority of IntentService in Android

I was wondering if it is possible to set the priority of an IntentService like you can with a Thread. So far I have not found anything. ...

PHP Concurrency via Cron

I have a few scripts that need to run concurrently as separate processes. My plan is to have a cron job that executes multiple instances of these scripts at a set interval. Is this a good idea? What are the pros/cons to this approach? Are there any other options I need to consider? Bottomline: I'm trying to mimic multithreading. Any rac...