multithreading

Performing App Delegate method on main thread from secondary thread

I have a Iphone app with 2 threads. One is listening to the server, and the other is doing UIKit, OpenGl stuff. I need to run a method that updates a view from the secondary thread thats listening to a server on the main thread that handles the views so I used performSelectorOnMainThread:@selector"createGuessingView" withObject:nil wai...

(Java) A Client reading text from 2 servers in parallel. How to implement?

Hi guys, Quite new here I am, I want to implement the scenario where a client reads data (Line) from 2 servers at the same time in parallel. I have been looking at examples over the net but nearly all the cases refer to multiple clients and a single server. The client after receiving the lines which consists of strings in parallel from...

Basic Prblems Android, need to know where to find Information, need Advice

Hey folks, I really like your site and I think this is the place where I find answers to my questions! I am planning an app, which shall do a couple of things but since I'm kind of lost in all the information conserning Android I really need some advice what I have to look out for and which of my goals might turn out tricky. I want to do...

simultaneous files downloading in python and qt

Hi there. In my program I need to download 3-4 files simultaneously (from different servers which are quite slow). I'm aware of the solution involving python threads or qt threads, but I'm wondering: since it seems to be a quite common task, maybe there's a library which I feed with urls and simply receive the files? Thanks in advance! ...

Specify if current thread is main thread or not

Is there any way to specify if current thread is main thread or not in objective-c? I want to do something like this. - (void)someMethod { if (IS_THIS_MAIN_THREAD?) { NSLog(@"ok. this is main thread."); } else { NSLog(@"don't call this method from other thread!"); } } ...

Semaphore.WaitOne/Release vs Monitor.Pulse/Wait

For me now it looks like functionally Semaphore.WaitOne/Release is equal to Monitor.Wait/Pulse. Skipping interprocess capabilities, speed (yes, Monitor is managed) other nonfunctional differences, what is real difference then? ...

Is there an interface wrapper around the Task Parallel Library so that I can swap it out for unit testing?

I asked this question a while ago. I now know it is a Bad Idea and that encapsulating the scheduling and running of tasks should be abstracted so that one can pass in a synchronous scheduler from the unit tests. I've currently got code that uses the Task Parallel Library (TPL) and I'd like to inject something like ITaskScheduler into ...

Please help me -- c# web application I need to load 3 user controls at the same time

I have a page that has 3 used controls that are dynamically added to the page. One of these use controls hits a class that pulls a record set from the database (a rather quick request) and the other 2 user controls hit a single class and return a dataset from the database. The 2 that share a single class take an average of 10 seconds t...

Is there a way to throttle the threads used by Task Parallel Library?

I'm using the TPL but I'm finding it tricky unit testing code that uses it. I'm trying to not introduce a wrapper over it as I feel it could introduce issues. I understand that you can set processor affinity in the TPL, but what'd be really nice is to set a thread maximum (probably per app-domain). Therefore, when setting the thread m...

Downloading a file from the Internet while being able to abort the download any time

Hello All! I'd like to download a file from my Delphi program in a separate thread dedicated to the download. The problem is that the main program can be closed any time (thus the download thread can be terminated any time as well). So even if there is no connection or the server lags for precious seconds I need a way to terminate the ...

Is it safe to to self destruct an NSThread?

Hey all, I have a pretty standard setup. I have a UIViewController to handle user interaction and a somewhat long running NSThread that does the actual work when the UI Controller shows up. One issue I've had is when I want to cancel the NSThread. Standard NSThread semantics is alright. I want the thread to finish, clean itself up (so t...

python threading: memory model and visibility

Does python threading expose issues of memory visibility and statement reordering as Java does? Since I can't find any reference to a "Python Memory Model" or anything like that, despite the fact that lots of people are writing multithreaded Python code, I'm guessing that these gotchas don't exist here. No volatile keyword, for instance....

How do I block until a thread is returned to the pool?

As part of a windows service I'm accepting incoming socket connection using myListener.BeginAcceptSocket(acceptAsync, null) The acceptAsync function executes on a seperate thread (just as expected). When the service is requested to shutdown, I "signal" the threads that accepted and are currently working on the sockets, to finish up. ...

Properly setting up a simple server-side cache

I'm trying to set up a server-side cache properly and I'm looking for constructive criticism on the setup I have currently. The cache is loaded when the Servlet starts and never changed again, so in effect it's a read-only cache. It obviously needs to stay in memory for the lifetime of the Servlet. Here's how I have it set-up privat...

Why this thread safe queue, creates a deadlock?

I've written my own version of thread safe queue. However, when I run this program, it hangs/deadlocks itself. Wondering, why is this locks/hangs forever. void concurrentqueue::addtoQueue(const int number) { locker currentlock(lock_for_queue); numberlist.push(number); pthread_cond_signal(&queue_availability_condition); } i...

Make all threads sleep

I work with new Parallel.For that creates multiple threads to perform the same operation. In case one of the threads fail, it means that I'm working "too fast" and I need to put all the threads to rest for a few seconds. Is there a way to perform something like Thread.Sleep - only to do the same on all threads at once? ...

create a new hibernate session in multi-thread program

How to create a new hibernate session at a new thread ? The SessionFacatory was managed by Spring. ...

what is the execution order of a threaded and non-threaded function call?

hello, i have written a simple console application just to try boost::thread, i am a multithreading newbie by the way. here is the code #include <iostream> #include <boost/thread/thread.hpp> #include <windows.h> using namespace std; void Avg(double * Src, double *Dst, int Per, int Len, string& s ) { LARGE_INTEGER s1,s2,f; Que...

A Strange C++ code problem in NDK, Nexus One

Hi guys. I got a strange problem when I run my app on Nexus One, Android 2.2. In my app, I used a native .so lib, built under NDK. In Java code, I have 2 threads: one UI thread, one to run codes from native so lib, and then updates the UI with the result data. In C++ code, I have a global variable "int count", which records the times a s...

Boost.Thread or just::thread ?

I am not yet a Boost user. I am however planning to go into it as soon as possible. However I am little concerned about Boost, and the likely future name collisions or differences with the forthcoming C++0x. (Maybe it is not a real issue, but for example I find the boost lambdas syntax pretty ugly, BOOST_FOREACH aggressive to the eye, an...