multithreading

using update statement in toplink in multithreaded environment

hi, i am using toplink, but i am getting some problem while updating the values. this is my code snippet ExpressionBuilder builder = new ExpressionBuilder(); Expression expr = builder.get("addressId").equal("2"); Address address1 = (Address)uow.readObject(Address.class, expr); address1.setPincode(address1.getPincode() + 1); uow.register...

Ping a network using threads and testing it

I am trying to ping two different networks with thread. I am able to get the response I want but I want to convert it into a test. I have the code that I have tried below but the test runner says that no tests were run. The code is below: #!/home/workspace/downloads/Python-2.6.4/python from threading import Thread import subprocess, un...

what is the difference between synchronous apis and asynchronous apis ?

I want to know about the synchronous apis and asynchronous apis in operating system. What is the difference between them ? ...

Background saving with Core Data?

Hi, I have a Core Data based iPhone application that needs to save 1000 managed objects on termination. This takes 8+ seconds, however, the OS kills the app if it does not complete in approx. 6 seconds. I don't want to save the objects earlier, because then the user has to wait 8 seconds longer for the results to display. Is it possib...

G++ CAS (__sync_val_compare_and_swap) problem needs explaining

Hi, This is doing my head in. I'm trying to implement some "lock-free" code and am using CAS (gcc __sync_val_compare_and_swap) to do he heavy lifting. My problem can be shown with the following code. volatile bool lock; void *locktest( void *arg ) { for ( int i = 0 ; i < 100000 ; ++i ) { // acquire a lock while...

Loading images into NSArray using initWithObjects crashes but not with an NSMutableArray?

I'm doing some lazy loading of images into an array when the app has loaded. I have tried using an NSMutableArray and an NSArray (I don't need to alter the array once it's been created) but the latter crashes on me. ... [self performSelectorInBackground:@selector(loadImageArrays) withObject:nil]; ... - (void)loadImageArrays { NSAu...

How can I accept multiple TCP connections in Perl?

I have a problem with Perl script for Linux. It's main purpose is to be middleman between 3 applications. What it should do: It should be able to wait for UDP text (without spaces) on $udp_port When it receives that UDP text it should forward it to the TCP client that is connected Problem is my app currently works until the first t...

C# Threading Lock error when merging images.

I'm trying to make a multithreaded program that takes a certain bitmap from a picturebox where each thread analyzes and changes part of it and then saves it back to the picturebox. I've used a lock() for the instructions that deal with the shared bitmap object and the picturebox but for some reason i still get "Object is currently in use...

Reorder NSOperationQueue

I'm looking for a way to reorder an NSOperationQueue. I could cancel all the operations and toss them back in using the order I want, but I was hoping for something a little bit cleaner. Any thoughts? ...

Concurrent execution/Re-entrant /ThreadSafe/???

Hello, I read many answers given here for questions related to thread safety, re-entrancy, but when i think about them, some more questions came to mind, hence this question/s. 1.) I have one executable program say some *.exe. If i run this program on command prompt, and while it is executing, i run the same program on another command ...

Tracking the process of a singleton process in a web application

When I hit the run button (in my Default.aspx), a process starts (this process contacts a webservice to get some files, etc). How do I: Ensure that only a single process is running at a time (i.e. if I refresh the browser, I don't want to start the process a second time) Track progress - there are 4 points of the process (at 25%, 50%,...

How to explain the "deadlock" better?

I am struggling to explain "deadlock" in threads in easy words, so please help. What could be the best example of "deadlock" (say, in Java), and how it does happen in steps and how to prevent it? But without getting into details too deep. I know that's like asking two opposite things, but still. If you have any previous concurrent progra...

How would you change my Heartbeat process written in C#?

I'm looking at implementing a "Heartbeat" process to do a lot of repeated cleanup tasks throughout the day. This seemed like a good chance to use the Command pattern, so I have an interface that looks like: public interface ICommand { void Execute(); bool IsReady(); } I've then created several tasks that I want...

Pattern for designing a scalable web service

I am writing a web service in Java which needs to handle a large number of requests / second. The general flow will be: Web service receives a request from client Returns a 'keep polling me' response to client Calls another web service (or services), and waits for them to respond (with a timeout) Client polls our web service, until it ...

Does pthreads provide any advantages over GCD?

Having recently learned Grand Central Dispatch, I've found multithreaded code to be pretty intuitive(with GCD). I like the fact that no locks are required(and the fact that it uses lockless data structures internally), and that the API is very simple. Now, I'm beginning to learn pthreads, and I can't help but be a little overwhelmed wit...

uiview animation threading issue

i am using two UIView animations to move the two different balls to particular position. But the timing of collision varies. First time they collide but second time first ball come first or viceversa. Can any buddy explain how to make them collide at same point using uiview animation. is it the thread processing issue of uiview animation...

How to get a form to refresh when there's intense code working in the background?

I have a Windows form that I'd like to be able to refresh with a status of the work that's going on in the background in different threads. Problem is, even if I change the label on the form, it doesn't immediately refresh; it seems that the work happening on the other worker threads is preventing the screen from updating. How do I for...

Multithreaded JavaScript how to?

Is there any idea (library or methodology) to create multithreaded apps in JavaScript? ...

Blocking queue for thread producer/consumers for win32/C

I'm trying to replace some thread communication with a custom queue, producer is currently using PostThreadMessage, consumer is using WaitForSingleObject/PeekMessage. http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html would be what I needed, but boost nor C++ is not an optio...

What are good ways to induce threading problems

I am finishing off testing a multi-threaded application that seems to work fine until I put it under heavy load and then stress the machine it is running on as well. Then I start seeing some of the stranger edge-cases that I did not foresee produce some unexpected/unforeseen conditions. The way I am stressing the machine is by running a ...