multithreading

Cocoa Thread error

I'm just getting started with using threads in obj-c/cocoa and I'm running into some trouble.. I get this error in the console: 2010-02-15 09:18:41.467 Timer[1007:4503] *** __NSAutoreleaseNoPool(): Object 0x10012adc0 of class __NSCFDate autoreleased with no pool in place - just leaking 2010-02-15 09:18:41.478 Timer[1007:4503] *** __NSAu...

java threads synchronization

In the class below, is method getIt() thread safe and why? public class X { private long myVar; public void setIt(long var){ myVar = var; } public long getIt() { return myVar; } } ...

Can Cron jobs be used to simultate multi threading with PHP?

I have a mysql database table filled with 1000+ records, lets say 5000 records. Each record has a processed boolean flag, default to false (0). What I'd like to do is have a PHP script run on cron every minute. Its code would be something like this: <?php process(); function process() { $sql = "SELECT id FROM items WHERE processed =...

Can one specify the thread that the AsyncCallback runs on when using delegate.BeginInvoke?

From my understanding of .NET, if I use a BackgroundWorker and have an event handler for RunWorkerCompleted, the event handler will run on the same thread in which RunWorkerAsync was called. If instead I use BeginInvoke on a delegate to run a method asynchronously, and pass an AsyncCallback parameter to BeginInvoke, is there any way I c...

twisted.web2 and spawining threads for synchronous code?

So, I'm writing a python web application using the twisted web2 framework. There's a library that I need to use (SQLAlchemy, to be specific) that doesn't have asynchronous code. Would it be bad to spawn a thread to handle the request, fetch any data from the DB, and then return a response? I'm afraid that if there was a flood of requests...

Unwind a function call

This is a difficult problem to describe so please let me know if anything is unclear. I am trying to solve a possible deadlock situation in my C++ app and I am having trouble visualizing an appropriate solution. The restrictions placed on me by the two libraries I am trying to connect make my problem very complex and troublesome but it...

What happens if a TimerTask takes longer to execute than the specified interval?

When using Timer.schedule(TimerTask task, long delay, long period) (i.e. with fixed-delay execution), what happens if the specified TimerTask's run() method takes longer than period to complete? Is it possible that two concurrent TimerTask threads will be running because of this? And if so, is there a way to avoid it? ...

Using Intel Threading Building Blocks (TBB) in Linux

Hi, I want to use Intel Threading Building Blocks (TBB) in Linux. Can anyone suggest a good IDE for that and possibly any steps to integrate TBB with that IDE? Thanks, Rakesh. ...

start/stop thread in ctor/dtor or better use start()/stop()?

I've a class that internally uses a worker thread. Currently the ctor starts the thread and the dtor stops (and waits for) it. Is this considered good code? I think it would be better to have separate start() / stop() functions for this purpose. One of the problems is that stopping and waiting for the thread may throw exceptions, which ...

Simple Multithreading Question

Ok I should already know the answer but... I want to execute a number of different tasks in parallel on a separate thread and wait for the execution of all threads to finish before continuing. I am aware that I could have used the ThreadPool.QueueUserWorkItem() or the BackgroundWorker but did not want to use either (for no particular re...

Set timeout to an operation

Dear C# geeks, I have object obj which is 3rd party component, // this could take more than 30 seconds int result = obj.PerformInitTransaction(); I don't know what is happening inside. What I know is if it take longer time, it is failed. how to setup a timeout mechanism to this operation, so that if it takes more than 30 seconds ...

How to populate thread safe a ListView in c#?

I need to put some ListView populate code in a thread. For the simple case, this thread should not run twice. When I want to issue a new thread the previous needs to stop, whatever did. EDIT 1 The scenario is the following. I have a textual filter above the ListView. On textchange I call a populateList() method. The problem is that the...

Why are threads called as light weight processes

Thread is "lightweight" because most of the overhead has already been accomplished through the creation of its process. I found this in one of the tutorial. Can somebody eloberate what it exactly means? ...

Making datasets thread safe in C#

What's the best pattern for making datasets threadsafe on write? The best I can find by googling is 'implement a wrapper layer with locks' but at first blush this seems rather messy. Can someone recommend / point me in the direction of a good solution to this? It seems likely to be a problem that has already been solved somewhere. ed...

Should I run everything in a background thread?

I am designing an application which has the potential to hang while waiting for data from servers (either Database or internet) the problem is that I don't know how best to cope with the multitude of different places things may take time. I am happy to display a 'loading' dialog to the user while access is happening but ideally I don't ...

Performing a pointer swap in a double-buffer multithread system

When double-buffering data that's due to be shared between threads, I've used a system where one thread reads from one buffer, one thread reads from the other buffer and reads from the first buffer. The trouble is, how am I going to implement the pointer swap? Do I need to use a critical section? There's no Interlocked function available...

Question about QThread implementation

Hi, A QThread object represents a single thread of execution. But is the OS thread created when the QThread object is created, or when the start() method is called? I'm interested in whether I can have several QThread objects lying around, and the OS will create threads on start() and kill them after run() returns, and then I can reuse...

Using Spring threading and TaskExecutor, how do I know when a thread is finished?

Alright, possible a naive question here. I have a service that needs to log into multiple network devices, run a command on each and collect the results. For speed, rather than collect the information on each device in sequence, I need to access them all concurrently and consume the results after they are done. Using the Spring framew...

java : spawning new thread is causing original threrad to halt

I have the following code in which I spawn a thread listen which is supposed to constantly listen to any incoming TCP messages, after this thread is run I want the main thread to be used for sending messages but as soon as I initiate listen.run() it seems that main thread does not run any further. I want it to continue to run the while l...

Why can't I see elements in a shared queue from my Perl thread?

I will listen on a port (simple server) when a request is passed parse the URL and start a thread. The thread will insert an element in a queue which is shared, and it is locked while inserting. I am not able to get element when I call peek on queue. use Thread qw(async); use Thread::Queue; my $DataQueue:shared = new Thread::Queue;...