multithreading

J2EE specification and multi threading

Hi guys, I am writing a J2EE application using Struts and Spring. In one of the operations there is heavy database processing, and hence performance issues. What I want to know is can I use multithreading here? I think the J2EE specification does not allow custom threads to be created apart from those created by Server(I use Weblogic...

iPhone Thread problem

Hello, I have an app which got 4 TableViewController which each make an instance of an RSSParser and have a function called commonInit which starts the parsing. Inititally i called the commonInit from the default init function in the TableViewController and it works fine but in case of no internet access I would get 4 alert windows whic...

Can ++ (increment) be called atomic?

Possible Duplicate: Ive heard i++ isnt thread safe, is ++i thread-safe? Hi all, Yesterday I did interesting investigation on behavior of ++ operator in multithreaded environment. I knew for a long time that this code is not thread safe: (C-like pseudocode) int i = 0; thread() { for (int j = 0;j < 1000000;j++) { ...

Core Text: counting pages in background thread

Let's say I'm writing text viewer for the iPhone using Core Text. Every time user changes base font size I need to count how many pages (fixed size CGRects) are needed to display the whole NSAttributedString with given font sizes. And I would like to do this in separate NSOperation, so that user does not experience unnecessary UI lags....

Implementing producer consumer problem using mutex

#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <semaphore.h> #define WORK_SIZE 1024 pthread_mutex_t work_mutex; char work_area[WORK_SIZE]; void *thread_start(void *); int main() { pthread_t a_thread; pthread_mutex_init(&work_mutex,NULL); pthread_create(&a_thread,NULL,thread_st...

Pass by reference TCL - threading?!

I'm using the Snack audio processing kit along with TCL. I want to cut up part of the sound and give this section to another thread to work with. My question is how to pass something by reference, between threads in TCL. proc a {} { snack::sound snd thread::send -async $Thread [list B snd] } set Thread [thead::create { ...

ReentrantLock Exceptions

I'm developing for Android 2.2, and a bit confused as to how ReentrantLocks work. Can the following code ever throw an IllegalMonitorStateException? I ask because I don't see how it can--according to the API, tryLock returns true if and only if the lock is successfully obtained--but occasionally the unlock() command does. public voi...

QThread blocking main application

I have a simple form UI that has a slot for a button, starting a thread: void MainWindow::LoadImage() { aThread->run(); } And the run() method looks like this: void CameraThread::run() { qDebug("Staring Thread"); while(1) { qDebug("ping"); QThread::sleep(1); } } When I click the button that calls...

keep alive thread in PyQt4

Hey, I have a PyQt4 application, which at some point packs a big file using the tarfile module. Since the tarfile module does not implement any callback strategy, it blocks and the Qt GUI gets unresponsive. I want the GUI to keep updating during that time. The only possibility is a separate thread. So, I start a QThread. What do I have...

Java volatile modifier and synchronized blocks

Does a variable that is accessed by multiple threads, but only inside synchronized blocks, need the volatile modifier? If not, why? ...

Django multi-threaded and mod_wsgi

Hi, First of all my site is up and running OK. There is no critical issues. I want to understand a couple of things though. I'll start with an overview of my system. It's a django-powered site located on a CentOS 5.3 VPS with 256MB RAM, under apache with mod_wsgi. The django application runs as a Daemon process with 1 threads. What...

a race condition or not? delegates & multiple threads

Hi all, I'm puzzling over how multithreading can work with delegates. The main thread has an object "A", which has created an object "B". Object "A" is the delegate for object "B". Object "B" uses a thread to run the code. When object "B" wants to notify the delegate, it does: [[self delegate] performSelectorOnMainThread:@selector(di...

Threading only block the first thread

I have the scenario where a command comes in over a socket which requires a fair amount of work. Only one thread can process the data at a time. The commands will come in faster than can process it. Over time there will be quiet a back log. The good part is that I can discard waiting threads and really only have to process the last one...

sending broadcast intent from runnable.

I want to send a broadcast from a new thread is start. This is what i tried : new Thread(new Runnable() { public void run() { //some other code for timing. // .. // .. Intent broadcastIntent = new Intent(); broadcastIntent.setAction(Intent.ACTION_ANSWER); ...

Resource or tutorial on Multi threading

Can anyone please guide me to a concise, succinct explanations to the multi threading concepts(mutex, semaphores, race conditions etc.) online. I've read a few books but none of them could really articulate the concepts. Sorry for this naive question, and thanking all of you in advance! ...

What are the disadvantages of using this asynchronous logging code?

Some code I just wrote follows. It demonstrates applying a PostSharp aspect to a method for the purposes of recording the duration of the method invocation in an asynchronous manner - so that if the logging process is slow then this performance penalty is not seen by the caller of the method decorated with the aspect. It seems to work...

Two threads using the same variable, produces a problem.

I have a List and two threads that using the List. The first thread is getting new connections, each new connection is added to the List. The second thread looping over the List to handle the connections (using foreach). The problem is that sometimes while the second thread is looping over the List, the List changes before the loop en...

High performance wcf

How do I maximize performance for my wcf service? Is it possible to take advantage of multicore? or multi-threading? Thanks!! ...

C# multi-threaded reading of unmodifiable collections

I have a dictionary which is filled once in a static constructor and stays unchanged ever since. I want multiple threads to be able to read values from this collection. Do I need any locking here? ...

Perl/MySQL "Query was empty" error, probably multithreading-related

I am writing a program to extract data from a bunch of text files and stuff it into DB. All of my commands currently have the form similar to this (with different queries): $query = "INSERT INTO relations (relation_type_id, confidence) VALUES ($reltypeid, $conf)"; print "$query\n"; $result = $conn->query($query); $relid = $result->inser...