multithreading

How to implement simple multithreaded function

Hi I need to implement simple function that is called from multiple threads. The logic of the function is simple - think of horse races - only the first horse can get golden medal once we have a winner the race is over. class ConditionalOrderGroup { private volatile bool _locked = false; private List<ConditionalOrder> _Conditio...

Running more than 2 threads inside 1 class.

Hey Guys, I've got a class which starts a new thread by calling public void omnom(){ t = new Thread(this, "My Thread"); t.start(); } The new thread then runs inside the run() method. So I have two threads working fine but how would I add a third? I'd like to "split" off 2 threads e.g t.start(); + f.start(); how would I split o...

Apache + Tomcat with mod_jk: maxThread setting upon load balancing

Hi, I have Apache + Tomcat setup with mod_jk on 2 servers. Each server has its own Apache+Tomcat pair, and every request is being served by Tomcat load balancing workers on 2 servers. I have a question about how Apache's maxClient and Tomcat's maxThread should be set. The default numbers are, Apache: maxClient=150, Tomcat: maxThread...

C# - How to access a remote thread?

Hello, First I'm going to explain what I'm trying to do, before asking the question directly. Basically, there is a Windows Service running on a specific machine, let's call it M1. This Windows Service runs a set of tasks using threads (1 thread for each partition of tasks). I need to program a functionality that will let the user stop/...

Multithread debugging techniques

Hi, I was wondering if anyone knows of a nice survey of debugging techniques for multithreaded applications. Ideally, I'm looking for a case-based analysis: deadlocks, starvation, corrupted shared state, ... .Net specific, or generic. ...

ThreadFactory usage in Java

Can someone briefly explain on HOW and WHEN to use a ThreadFactory? An example with and without using ThreadFactory might be really helpful to understand the differences. Thanks! ...

*nix System-wide threads and processes mutex

I have some resource which I'd like to protect from concurrent usage both by threads in the same process and among different processes. What is the "right" way of doing it in *nix? E.g. we want to write to a file from a multithreaded app, which once in a while forks some subprocesses. How to ensure that each thread has exclusive access ...

C# - How to get an instance of a thread from its name/id?

Hi, Is it possible to get the instance of a specific running thread knowing its name or id? If yes, how? Thank you ...

Render to texture in different thread on iPhone

Hello! In my iPhone game I use separate thread to load resources. I use multiple EAGLContext's. Sometimes I need to render to texture in this background thread. But all I get is the black 1024*1024 texture. How do I render to texture in one thread while other thread is performing screen rendering? ...

.NET How to perform "sequential" thread utilization

I am using a multi-threaded producer/consumer queue with a single (very fast) producer and many, much slower, consumers. Each consumer has exclusive access to a piece of physical hardware, such as a phone line. The producer runs on the main thread and each consumer runs on its own thread. Each consumer thread is created and initialize...

Correct way of checking if threads are done?

I'm using multithreading in my application with _beginthread and right now to wait until all threads are done I have global bools that get set to true as each thread completes so I'm in a while loop until then. There must be a cleaner way of doing this? Thanks ...

Java very limited on max number of threads?

We have a small text box with 512Mb of ram. We wanted to see how many threads we can create in Java in this box. To our surprise, we can't create many. Essentially the minimum stack size you can set with -Xss is 64k. Simple math will tell you that 64*7000 will consume 430Mb so we were only able to get it up to around 7000 threads or so a...

What is threading model in ASP.NET ?

ASP uses STA threading model while ASP.NET uses MTA. What does it mean ? ...

Visual presentation of threading versus message passing and actor models

I'm looking for a good slideshow/pdf/video explaining the differences in approach and thinking from hand-written threading of applications compared to the more abstracted and easier to use message passing and actor models. Does anyone know of existing resources to explain these concepts with good diagrams and visualizations? ...

Java Swing - UI Freezing

Hi, I'm doing some routine in Java (1.5)+Swing, that damands some time. How the best way to implement this routing outside the swing thread, to avoid UI freezing? Thanks in advance ...

What's the good way to synchronize calls to a NSView?

Hey guys, I have a view that receives new data from a secondary thread. Every time it does, it should redraw itself. However, it doesn't play nice with the run loop, and after some time (it's non-deterministic), I end up getting <Error>: kCGErrorIllegalArgument: CGSUnionRegionWithRect : Invalid region messages in the console. I'm not s...

Can a batch file execution step through sequence without completing a java process?

Does a batch file execute processes in sequence only if the previous step has completed and released all file/process locks? Suppose I have the following cmd file (mybatchfile.cmd) echo. |TIME java myjar.jar echo. |TIME and I pipe the results to a log file. Can I be 100% confident (on windows) that my java process has completed and...

How to improve performance by processing database results in parallel?

Hi all, I have a .net application which runs in the region of 20 to 30 SQL queries and processes the results 1 at a time. I have been trying to increase performance by doing some work in parallel. 2 of the queries take 75% of the time, purely because of the amount of data they return. My initial experiments have been to try to split th...

Limiting Self Expanding Tasks

Background: I'm using .NET 4.0 and the new Task class. Using the code found at http://msdn.microsoft.com/en-us/library/ee789351.aspx I've implemented a Task Scheduler that limits the number of concurrent threads executing. I've also modified the code to use the BlockingCollection instead of LinkedList for my lists of tasks so I can limit...

Android GPS Callback off UI Thread

I'm having trouble getting the GPS's onLocationChanged to run on a different thread. I understand how to manage UI thread when I'm calling a function but with the GPS, I don't actively call the function. My intent is to have a light flash every time the GPS receives a reading. I have put this function in a Runnable. I passed this funct...