multithreading

Starting a threaded process 60 minutes after a file upload

I have a website that allows a user to upload a spreadsheet of items to a database. When the spreadsheet is uploaded it will be assessed for keywords that match individual user interests and email those users an alert to visit the website. However, when the spreadsheet is successfully uploaded the administrator needs to ftp into their se...

Server multithreading overkill?

I'm creating a server-type application at the moment which will do the usual listening for connections from external clients and, when they connect, handle requests, etc. At the moment, my implementation creates a pair of threads every time a client connects. One thread simply reads requests from the socket and adds them to a queue, an...

Thread Vs javax.swing.Timer, controlling game animation in Java?

Hi, I have this very straight forward question regarding Thread and Timer classes in Java as a way of creating game animations. Which is better of the two? What are really the differences between the two and which is the most preferred in terms of animation in Java? I hope my question makes since, this is in someway related to the answer...

iPhone SDK - Search Bar Thread Synchronization Question

This is more of a high level "how do you solve this type of problem" type of question, as opposed to a "why doesn't my code compile" question. I've got a search bar within an iPhone application that searches my data just fine. However, i have the search triggered (handleSearchForTerm is called) after each keypress. This creates some l...

How to tell if a thread is the main thread in C#

I know there are other posts that say you can create a control and then check the InvokeRequired property to see if the current thread is the main thread or not. The problem is that you have no way of knowing if that control itself was created on the main thread. I am using the following code to tell if a thread is the main thread (the ...

ReleaseSemaphore does not release the semaphore

(In short: main()'s WaitForSingleObject hangs in the program below). I'm trying to write a piece of code that dispatches threads and waits for them to finish before it resumes. Instead of creating the threads every time, which is costly, I put them to sleep. The main thread creates X threads in CREATE_SUSPENDED state. The synch is done...

Which pointer to delete?

I'm trying to multithread something and i have my program set up such that i have a structure/class of variables that will be passed into each thread for processing. In this class, there are variables that hold pointers to arrays some threads have common arrays from which they read data off of, instead of duplicating those arrays, point...

SWT single threading problem

Hi, I faced a problem while using threading for the first time, In an SWT program in the main thread I have created the GUI and opened the shell, and then a new thread is started to run some logic in the model, and in the model at a certain state there is a method is called in the GUI class... and here it is the problem this method is c...

Android: Stopping method to be called twice if already running.

I'm trying to prevent my application to call the same method twice in the event of a double-click, or if the user presses different buttons quickly, almost at the same time. I have clickable Views, acting as buttons, that call the same method but passing different parameters. This is the call: startTheSearch(context, getState(), what, ...

How to do compare and increment atomically in C/C++

In my attempt to develope a thread-safe c++ weak pointer template class, I need to check a flag that indicating the object is still alive, if yes then increment the object's reference count and I need to do the both steps atomically. I know the existance of intrinsics functions provided by the compiler for instance _InterlockedCompareExc...

Need help on python sqlite?

1.I have a list of data and a sqlite DB filled with past data along with some stats on each data. I have to do the following operations with them. Check if each item in the list is present in DB. if no then collect some stats on the new item and add them to DB. Check if each item in DB is in the list. if no delete it from DB. I canno...

How to check apartment state of current thread?

I have a function which requires to be run in STA apartment state. I wan't to check if it is being run as STA, and if not spawn a new thread which runs in STA. How can I check which apartment state the current thread is being run in? ...

Passing delegate with return type other than void in thread

I want to pass a delegate with the return type as ArrayList as parameter of thread and want to store the values in an ArrayList as well. Any help in this regard will be appreciated. ...

C#/.NET analysis tool to find race conditions/deadlocks

Is there a tool that analyses .NET code and finds race conditions? I have a bit of code that has a public static property that gets or creates a private static field. It also has a public static method that sets this field to null (...yes, I know!..) As there are no locks around either of these methods, it's a safe bet that things'll ...

Using condition variable in a producer-consumer situation

Hello, I'm trying to learn about condition variables and how to use it in a producer-consumer situation. I have a queue where one thread pushes numbers into the queue while another thread popping numbers from the queue. I want to use the condition variable to signal the consuming thread when there is some data placed by the producing th...

Can hotshot be used in multiple threads?

I have a long-running multithreaded program, and I'd like to occasionally like to call a function with Profile.runcall and dump the data to a file. The hotshot documentation states: Note: The hotshot profiler does not yet work well with threads. It is useful to use an unthreaded script to run the profiler over the code you’re interested...

How to monitor a vital worker thread

I have a worker thread that is vital for my application. It is created with new Thread( method ).Start(); I don't join it, I just expect that is runs as long as my program runs. However, it can happen that there is an exception caught on this thread; and as a consequece the thread will (beside some last logging) shutdown. A recovery is n...

Problem : iPhone graphics go mad !

Helloo! I faced a really stranged problem recently. I am doing a timetable organizer, and I draw each event in a DayViewController with Quarz 2D, then I add a "glass effect" picture (PNG). But randomly, as I switch between days, the layout go really bad. Here is a link to see the good appearance and below the bad one : http://toucotton...

Django: start a process in a background thread?

Hi there I'm trying to work out how to run a process in a background thread in Django. I'm new to both Django and threads, so please bear with me if I'm using the terminology wrong. Here's the code I have. Basically I'd like start_processing to begin as soon as the success function is triggered. However start_processing is the kind of ...

Using callgrind/kcachegrind to get per-thread statistics

I'd like to be able to see how "expensive" each thread in my application is using callgrind. I profiled with the --separate-thread=yes option which gives you a callgrind file for the whole app and then one per-thread. This is useful for viewing the profile of any given thread, but what I really want is just a sorted list of CPU time ...