multithreading

Linux per-process resource limits - a deep Red Hat Mystery

I have my own multithreaded C program which scales in speed smoothly with the number of CPU cores.. I can run it with 1, 2, 3, etc threads and get linear speedup.. up to about 5.5x speed on a 6-core CPU on a Ubuntu Linux box. I had an opportunity to run the program on a very high end Sunfire x4450 with 4 quad-core Xeon processors, runni...

Multi-threaded random_r is slower than single threaded version.

The following program is essentially the same as the one described here. When I run and compile the program using two threads (NTHREADS == 2), I get the following run times: real 0m14.120s user 0m25.570s sys 0m0.050s When it is run with just one thread (NTHREADS == 1), I get run times significantly better even th...

Memory increases with Java UDP Server

I have a simple UDP server that creates a new thread for processing incoming data. While testing it by sending about 100 packets/second I notice that it's memory usage continues to increase. Is there any leak evident from my code below? Here is the code for the server. public class UDPServer { public static void main(String[] args)...

Pass off execution to different/specific thread in Java

I have about 4 threads. One thread keeps checking some data that the other thread is updating. The others are doing some processing in the background. All have been started at this point. My question is when the checking thread sees that the data has not been updated yet I currently sleep for a little bit but is there any way for me ...

Would watching a file for changes or redundantly querying that file be more efficient?

I am wondering whether watching a file/directory for changes using the FileSystemWatcher class is extremely memory intensive. I am developing a desktop application in C# that will be running behind the scenes continuously on low-performance computers, and I need some way of checking to see if various files have changed. I can think of a ...

PHP, Ajax, and the lifespan of the request

I was wondering about the lifespan of a PHP script when called via Ajax. Assume that there is a long-running (i.e. 30 seconds) PHP script on a server and that page is loaded via Ajax. Before the script completes, the user closes the browser. Does the script continue running to completion, is it terminated, or is this a function of the...

What is the correct way to synchronize a shared, static object in Java?

This is a question concerning what is the proper way to synchronize a shared object in java. One caveat is that the object that I want to share must be accessed from static methods. My question is, If I synchronize on a static field, does that lock the class the field belongs to similar to the way a synchronized static method would? Or, ...

Threading in C#

Hi All Just looking for something ultra simple. I need to spawn a method off to a new thread. I don't care when or how it ends. Can somebody please help me with this? Thank you ...

In threads, WaitForMultipleObjects never returns if set to INFINITE

Let say I have three thread handles HandleList[0] = hThread1; HandleList[1] = hThread2; HandleList[2] = hThread3; /*All the above are of type HANDLE*/ Before closing the application, I want the thread to get its task done. So I want to make app wait till thread completes. So I do, WaitForMultipleObjects(3, HandleList, TRUE, INFINITE...

XNA Multi-Thread Jitters

Hi guys, brand new question. Just implemented multi-threading into my XNA game as it was unable to keep up with using 1 processor. MT is all implemented fine and everything, however the player seems to jitter all over the spot every now and then. I originally thought it was a loss of data between the update and render, but even when i d...

Unique value in table using EF4 and locking

In this code, I have an Entity Framework 4 model with a single "Thing" entity that has an Id and a Name(string) column. I would like to ensure that when I call FindOrCreateThing(name) from multiple threads, only one row in the Things table will ever be created with the given name. Currently, I'm using locks to accomplish this, and it se...

which Thread makes stop all the world - Gc logs

I have found that gc logs without gc activites means that another activity that blocks the system. How can find which thread can cause the stop all the world on the system I have 8 CPU server. Why one thread is in a stuck (or in a loop), other threads cannot work simulteneously. They wait for the stuck Thread. Regards Trustin 49024K...

When to use a service in Android

Hi everyone, I have a class that fetches data in response to button presses in the main activity. Unfortunately, I keep running into problems because this class is not an Activity or a Service. For example, without a Context I cannot translate a resource id into a string: getString(R.string.example_string); // Doesn't work Should I m...

Is it safe to read global data from multiple threads?

The scenario is as follows: Create an instance of a class (std::map) and sore it as global variable. Spawn threads. Threads read and use the same global instance of the class (call methods, access members etc) All spawned threads quit Global class instance is destroyed No mutex used, no spawn thread modifies the global class instance...

Multi-threaded Application with Readonly Properties

Should my multithreaded application with read only properties require locking? Since nothing is being written I assume there is no need for locks, but I would like to make sure. Would the answer to this question be language agnostic? Without Lock: Private Const m_strFoo as String = "Foo" Public ReadOnly Property Foo() As String Get...

Datagridview retains waitcursor when updated from thread

I have a DataGridView control in my Windows Forms Application. I am adding rows to the grid using a background thread. I change the form's cursor to Waitcursor when the process starts and back to Default when it ends. This works well for the form, but not for the grid. When the form's cursor is changed back to default, the grid's cursor ...

How difficult is Haskell multi-threading?

I have heard that in Haskell, creating a multi-threaded application is as easy as taking a standard Haskell application and compiling it with the -threaded flag. Other cases, however, have described the use of a par command within the actual source code. What is the state of Haskell multi-threading? How easy is it to introduce into prog...

Threading and iterating through changing collections

In C# (console app) I want to hold a collection of objects. All objects are of same type. I want to iterate through the collection calling a method on each object. And then repeat the process continuously. However during iteration objects can be added or removed from the list. (The objects themselves will not be destroyed .. just remo...

android call an outside function from a thread

hi.. say for example I have this code in my activity: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Thread cThread = new Thread(new Runner()); cThread.start(); } private NotifyMe(){ //do something here } and this is my Runner class: ...

python threading and performace?

I had to do heavy I/o bound operation, i.e Parsing large files and converting from one format to other format. Initially I used to do it serially, i.e parsing one after another..! Performance was very poor ( it used take 90+ seconds). So I decided to use threading to improve the performance. I created one thread for each file. ( 4 threa...