multithreading

capture a call stack and have it execute in a different thread.

I need to write a logging api which does the actual logging on a seperate thread. i.e. I have an application which wants to log some information. It calls my API and the api captures all the arguments etc and then hands that off to a seperate thread to be logged. The logger api accepts variadic arguments and therefore my initial though...

Long Touch on a surfaceView ( android )

Hi! I'm making a game on Android and I need to do certain actions when the users attempts a long press on the screen. Unfortunately I haven't found any methods that works directly with a custom SurfaceView, feel free to tell me if such a method exists :) So I decided to try and implement a long touch detection from the onTouch event li...

Where do I start investigating my Java process that won't end?

I have a Java application which doesn't end. The main method finishes, but threads remain active and the application doesn't end. The thing is, there don't appear to be any monitor locks / waits, so I can't see why it's not ending. According to Eclipse, I am left with two non-Daemon threads. One is labelled [DestroyJavaVM] (looks hop...

Are static const variables thread-safe?

Hi all, I'm wondering whether static constant variables are thread-safe or not? Example code snippet: void foo(int n) { static const char *a[] = {"foo","bar","egg","spam"}; if( ... ) { ... } } ...

How do I force the main GUI thread to update a listbox after it is updated from a different thread?

I'm tinkering away on a multithreaded downloader, using a producer/consumer queue construct; the downloading parts works fine, but I'm running into a problem keeping the GUI updated. For now I'm using a listbox control on the form to display status messages and updates on downloading progress, eventually I hope to replace that with prog...

Should you always use an ExecutorService instead of starting your own thread?

With JDK >= 1.5, should the preferred way to start a thread always be an Executor or Executor Service, or are there still reasons to prefer to use a Thread.start if you don't need what an ExecutorService provides? For syncronized, I used to think that using the new Lock implemenations was preferred, until I was explained otherwise. So I...

does animateWithDuration:animations: block main thread?

I have connected the two methods below to separate buttons in my UI but have noticed that after pressing the "VERSION 1" button that I could not press the button again until the animation duration within the method had ended. My understanding was that the animation uses its own thread so as not to block the main application. // VERSION ...

Do threads created in Java behave differently on Windows and Linux?

As what I know, Java is using operating system threads (in contrast to i.e. Erlang), that means that the threads created with Java on Windows and Linux may behave different. Are there any differences on Java threads on Windows and Linux? What is the biggest difference? It's maybe only a difference in performance? ...

Thread Synchronization problem in java

HI all, I am having a thread Checker (extends thread class) which keeps on decreasing the numbers from 1000 to 0 and stops when number reaches 0. Also the sleep time between the subtractions is 10 seconds hence it goes on like 1000, 990, 980..... and so on. This count is stored permanently and hence will not get reset to 1000 after it i...

shutdown Quartz Thread

Hi all, how i can stop those threads : Group[QuartzScheduler:DefaultQuartzScheduler:class java.lang.ThreadGroup] ? I've object ThreadGroup that contains it.... but how is the correct way to destroy it? Thanks! Tommaso ...

Updating TextViews in a separate thread

I am trying to make an application that can simulate a fight of two characters and I need to update some TextViews of their hp as it goes down. This is currently happening while two threads are running. Their hp is a global variable and since views can only be modified in the main thread, I have a while loop running while the threads are...

How does one stop a thread without a stop() method?

I have question about the Java threads. Here is my scenario: I have a thread calling a method that could take while. The thread keeps itself on that method until I get the result. If I send another request to that method in the same way, now there are two threads running (provided the first did not return the result yet). But I want t...

How to manage python threads results?

I am using this code: def startThreads(arrayofkeywords): global i i = 0 while len(arrayofkeywords): try: if i<maxThreads: keyword = arrayofkeywords.pop(0) i = i+1 thread = doStuffWith(keyword) thread.start() except KeyboardInterrupt: ...

Multiple Threads - do i need to lock on reading data?

look at this code: int data=5; void Thread1() { if(data==5) { //nothing } } void Thread2() { if(data==2) { //nothing } } in this case, do i need to use EnterCriticalSection/MutexLock before if(data==..) ? ...

What's the point of cache coherency?

On CPUs like x86, which provide cache coherency, how is this useful from a practical perspective? I understand that the idea is to make memory updates done on one core immediately visible on all other cores. This is a useful property. However, one can't rely too heavily on it if not writing in assembly language, because the compiler c...

Threading through a list of actions X threads at a time in C#

Let's say I have a List<Thread> df = new List<Thread>(); // I add 500 instances of delegate() { somemethod(a,b) }; to df Now I want to run through all df items threading it X items maximum at a time, how can I accomplish this? ...

What's the best way to abort a thread in my scenerio

I'm sorry if some other people have asked a similar question before. I have a simple GUI app which upload some files to a server. I put the upload work to a seperate thread. When users want to exit the application, a event will be set to notify the thread to exit normally. Then the UI thread will wait for it. The code I used to abort th...

Is Thread.Abort() corruption localized?

I understand that calling Thread.Abort() is BAD AND WRONG because of various reasons Can be locking or in other critical region Could be midway through an I/O operation, resource won't get cleaned up Code can swallow ThreadAbortException Could be midway through a state change operation, and leave the program in an invalid state. Assu...

Parsing files from a different server - using threads

I have this scenario. OS is UNIX. There are a bunch of files on Server A. The need is to FTP these files(they are in XML format) to server B, parse them and store the values retrieved from specific tags to a DB. Current implementation of the parser in perl is such that the files are processed sequentially. Can a multi-threading concept i...

NSOperationQueue dispatching threads slowly?!

I'm writing my first multithreaded iPhone apps using NSOperationQueue because I've heard it's loads better and potentially faster than managing my own thread dispatching. I'm calculating the outcome of a Game of Life board by splitting the board into seperate pieces and having seperate threads calculate each board and then splicing them...