multithreading

Context inside a Runnable

Hi, I try to play a sound from R.raw. inside a Thread/Runnable But I can't get this to work. new Runnable(){ public void run() { //this is giving me a NullPointerException, because getBaseContext is null MediaPlayer mp = MediaPlayer.create( getBaseContext(), R.raw.soundfile); while (true) { if (somethin...

When to use QThread::exec()

Hi, I've checked a satisfying explanation but could not find. Usually docs mention that in order to use signals/slots between threads, we need to use event loops and start them by calling exec. However I can see that w/o using exec(), I can still send signals and handle them across threads. What's the exact use of it? ...

How to wait for a thread to finish in Objective-C

I'm trying to use a method from a class I downloaded somewhere. The method executes in the background while program execution continues. I do not want to allow program execution to continue until this method finishes. How do I do that? ...

How should this code be changed to work correctly?

I downloaded some code from http://github.com/matej/MBProgressHUD to show a progress meter when doing something. This is the code that makes the progress meter pop up. [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES]; This will show a progress meter while the method myTask is running. The strange ...

How to use thread search method in imaplib?

I want to create a gmail client with the ability to view emails as conversations (threads). In imaplib, there is a method: IMAP4.thread(threading_algorithm, charset, search_criterion[, ...]) I think it could be the solution. Anybody has experience using it? Please give an example. Thanks. ...

Context.Undo() error, only on Windows XP machine

Hi, I have an asynchronous socket and I get the following error ONLY on ONE windows XP machine: The Undo operation encountered a context that is different from what was applied in the corresponding Set operation. The Undo operation encountered a context that is different from what was applied in the corresponding Set operation. The po...

C# Process - Pause or sleep before completion

I have a Process: Process pr = new Process(); pr.StartInfo.FileName = @"wput.exe"; pr.StartInfo.Arguments = @"C:\Downloads\ ftp://user:[email protected]/Transfer/Updates/"; pr.StartInfo.RedirectStandardOutput = true; pr.StartInfo.UseShellExecute = false; pr.StartInfo. pr.Start(); string output = pr.StandardOutput.ReadToEnd(); Console...

Delphi Access to Thread Variables

I have a thread that does a WMI query for me and I need to access some variables in the thread after it has executed the query. The thread is created as follows ... procedure TFormMain.RunThread; var WMIQ: TThreadWmiQuery; begin WMIQ := TThreadWmiQuery.Create(True); ... WMIQ.OnTerminate := WMIQThreadOnTerminate; WMIQ.Resume;...

In Brian Goetz Concurrency In Practice, why is there a while(true) in the final example of a scalable cache?

In code listing 5.19 of the Brian Goetz book Concurrency In Practice, he presents his finished thread safe Memoizer class. I thought I understood the code in this example, except that I don't understand what the while ( true ) is for at the start of the public V compute(final A arg) throws InterruptedException method. Why doe...

Memory management bottleneck to SMP Parallelism

Across multiple languages (mostly D and Java/Jython) I've noticed that parallel programs with no obvious synchronization bottleneck often don't scale well to 4 or more cores because of memory management bottlenecks. I'm aware that thread-local allocators mitigate this problem, but most garbage collector implementations still need to sto...

Multithreading in MySQL?

Are MySQL operations multithreaded? Specifically, on running a select, does the select (or join) algorithm spawn multiple threads to run together? Would being multi-threaded prevent being able to support a lot of concurrent users? ...

How to set the apartment state of the thread serving the .Net Remoting call?

The client and server of my program are both marked STAThread, and I verified in the debugger that the thread I make the call from is marked as STA. On the server side, I verified that the program itself when setting up the server is marked STA. However the actual .Net remoting call is done via a thread which is marked MTA. Is there anyw...

Does ThreadPoolExecutor spawns a new thread if a current thread sleeps

Hi, This question is a followup on this one. Essentially what I am doing is declaring a ThreadPoolExecutor with just one thread. I am overriding the beforeExecute() method to put a sleep so that each of my tasks are executed with some delay among themselves. This is basically to give away the CPU to other threads since my thread is ki...

Help with Java Multithreading

Alright, this is a sort of dual-purpose question. The main thing I hope to take away from this is more knowledge of multithreading. I am a complete newbie when it comes to multithreading, and this is my first actual attempt to do anything in multiple threads. The other thing I hope to take away is some help with a piece of homework that ...

WPF MVVM Multithreading Issue

Hi all. I've seen other issues similar to mine, but i haven't seen any that i can apply to make my code work. So i'm new to MVVM, and i'm trying to get some stuff that's executing in a background thread to update on my UI. What i'm noticing is that the first time bring up the UI, and the background thread executes the first time, if th...

How to pause a Thread's Message Queue in Android?

I am queuing up a bunch of runnables into a thread via a Handler.post(). I would like the ability to send a note to that thread that it should pause. By pause I mean, finish the runnable or message you are currently working on, but don't go to the next message or runnable in your message queue until I tell you to continue. ...

Why Thread.Sleep() is so CPU intensive ?

I have an ASP.NET page with this pseduo code: while (read) { Response.OutputStream.Write(buffer, 0, buffer.Length); Response.Flush(); } Any client who requests this page will start to download a binary file. Everything is OK at this point but clients had no limit in download speed so changed the above code to this: while (read)...

VB.NET Trying to modify a generic Invoke method to a generic BeginInvoke method, having unexpected problems

VB.NET 2010, .NET 4 Hello, I have been using a pretty slick generic invoke method for UI updating from background threads. I forget where I copied it from (converted it to VB.NET from C#), but here it is: Public Sub InvokeControl(Of T As Control)(ByVal Control As t, ByVal Action As Action(Of t)) If Control.InvokeRequired Then ...

parallel calculation of infinite series

Hi All I just have a quick question, on how to speed up calculations of infinite series. This is just one of the examples: arctan(x) = x - x^3/3 + x^5/5 - x^7/7 + .... Lets say you have some library which allow you to work with big numbers, then first obvious solution would be to start adding/subtracting each element of the sequence u...

Need Help Tracking Down EXC_BAD_ACCESS on Function Entry on MacOS

I have a program that gets a KERN_PROTECTION_FAILURE with EXC_BAD_ACCESS in a very strange place when running multithreaded and I haven't the faintest idea how to troubleshoot it further. This is on MacOS 10.6 using GCC. The very strange place that it gets this is when entering a function. Not on the first line of the function, but th...