multithreading

Wait for inline thread to complete before moving to next method...

Hello, I have an android app where I am doing the following: private void onCreate() { final ProgressDialog dialog = ProgressDialog.show(this, "Please wait..", "Doing stuff..", true); new Thread() { public void run() { //do some serious stuff... dialog.dismiss(); } }.start...

Catching the return of main function before it deallocates resources

I'm trying to implement user threads in Linux kernel 2.4, and I ran into something problematic and unexpected. Background: a thread basically executes a single function and dies, except that when I call thread_create for the first time it must turn main() into a thread as well (by default it is not a thread until the first call, which ...

Need a Java based interruptible timer thread

I have a Main Program which is running a script on the target device(smart phone) and in a while loop waiting for stdout messages. However in this particular case, some of the heartbeat messages on the stdout could be spaced almost 45secs to a 1minute apart. something like: stream = device.runProgram(RESTORE_LOGS, new String[] {}); str...

Best way to implement game loop without freezing UI thread

I'm trying to make a simple 2D game in Java. So far I have a JFrame, with a menubar, and a class which extends JPanel and overrides it's paint method. Now, I need to get a game loop going, where I will update the position of images and so on. However, I'm stuck at how best to achieve this. Should I use multi-threading, because surely, i...

Is Spring.Threading.Helpers still supported?

I am converting some old C# code, and it has a CountDownLatch using a package called Spring.Threading.Helpers. The odd thing is that I can't find this package on Google - so a) is it still supported? And, if so, where is it documented? b) What I really want to do is wait for a count to get to zero, but interrupt every so many msecs. ...

cancelPreviousPerformRequestWithTarget is not canceling my previously delayed thread started with performSelector

Hello, I've launched a delayed thread using performSelector but the user still has the ability to hit the back button on the current view causing dealloc to be called. When this happens my thread still seems to be called which causes my app to crash because the properties that thread is trying to write to have been released. To solve ...

C CLI game concept

So I just wanted to get some opinions on the overall structure of a game I have to build for a programming class. Essentially - I'm building two programs - a client and a server for a battleships game. I've already written the actual program which plays the battleships game. The program I've written is where a map and rules file is read...

Atomic variable Vs. Atomic operation

Hi, Lets say I have two shared variables - a and b - that are related to each other. When multiple applications share these shared variables, access to them needs to be an atomic operation, otherwise the relation may break. So to ensure mutual exclusion, I'll put their modification under a critical section protected by lock. critical_c...

User Control creating and hiding a form Threading issues

I've got a control called ChatController, as a private member I have: private frmChat m_chatWindow = null; In ChatController's constructor I do: m_chatWindow = new frmChat(strJobNumber, m_emailAddress); if (m_chatWindow.InvokeRequired) m_chatWindow.Invoke(new MethodInvoker(delegate { m_chatWindow.Hide(); })); else m_chatW...

Techniques for modeling a dynamic dataflow with Java concurrency API

Is there an elegant way to model a dynamic dataflow in Java? By dataflow, I mean there are various types of tasks, and these tasks can be "connected" arbitrarily, such that when a task finishes, successor tasks are executed in parallel using the finished tasks output as input, or when multiple tasks finish, their output is aggregated in ...

How can I prevent ADO from creating multiple SPIDs?

I'm working on an application that creates a single ADO connection and keeps it open for the lifetime of the application. I have connection pooling turned off. (Please ignore the fact that this might not be best practice for the purposes of this question). If I spawn a new thread and use the exact same ADO connection, it uses a new SPI...

C# regularly return values from a different thread

Hello, I'm very new to multithreading and lack experience. I need to compute some data in a different thread so the UI doesn't hang up, and then send the data as it is processed to a table on the main form. So, basically, the user can work with the data that is already computed, while other data is still being processed. What is the best...

Threads in Java

I was today asked in an interview over the Thread concepts in Java? The Questions were... What is a thread? Why do we go for threading? A real time example over the threads. Can we create threads in Spring framework service class. Can flex call a thread? I did not answer any questions apart from definition of Thread, that too I jus...

Requesting information from the user inside a GTK main loop

Hello, I am learning Python by building a simple PyGTK application that fetches data from some SVN repositories, using pysvn. The pysvn Client has a callback you can specify that it calls when Subversion needs authentication information for a repository. When that happens, I would like to open a dialog to ask the user for the credential...

Diffrernce between BackgroundWorker.ReportProgress() and Control.BeginInvoke()

What is the difference between options 1 and 2 in the following? private void BGW_DoWork(object sender, DoWorkEventArgs e) { for (int i=1; i<=100; i++) { string txt = i.ToString(); if (Test_Check.Checked) //OPTION 1 Test_BackgroundWorker.ReportProgress(i, tx...

How to prevent the other threads from accessing a method when one thread is accessing a method?

I want to search for a string in 10 files and write the matching lines to a single file. I wrote the matching lines from each file to 10 output files(o/p file1,o/p file2...) and then copied those to a single file using 10 threads. But the output single file has mixed output(one line from o/p file1,another line from o/p file 2 etc...) be...

Persistance Queue Implementation

I was reading an article on Batch Processing in java over at JDJ http://java.sys-con.com/node/415321 . The article mentioned using a persistence queue as a Batch Updater instead of immediately sending an individual insert or update to the database. The author doesn't give a concrete example of this concept so I googled Persistence Queue ...

Thread Jobs in Java

Hi, I want to spawn 200 threads simultaneously in Java. What I'm doing right now is running into a loop and creating 200 threads and starting them. After these 200 gets completed, I want to spawn another 200 set of threads and so on. The gist here is that the first 200 threads I spawned need to be FINISHED before spawning the next set....

Different standard streams per POSIX thread

Is there any possibility to achieve different redirections for standard output like printf(3) for different POSIX thread? What about standard input? I have lot of code based on standard input/output and I only can separate this code into different POSIX thread, not process. Linux operation system, C standard library. I know I can refact...

How to fire off a asych thread in a web application, and gaurantee only 1 thread fires?

I want to cache a object in memory. Regenerating the object when the cache expires is fairly expensive, so I want to do the following: When the cache is "about" to expire, I want to fire off a asychronous thread that will go and rebuild the object and then reset the cache. One thing I am worry about is multiple threads firing to fetch...