multithreading

Task oriented thread pooling

I've created a model for executing worker tasks in a server application using a thread pool associated with an IO completion port such as shown in the posts below: http://weblogs.asp.net/kennykerr/archive/2008/01/03/parallel-programming-with-c-part-4-i-o-completion-ports.aspx http://blogs.msdn.com/larryosterman/archive/2004/03/29/10132...

How can an application utilize multiple cores or CPUs in .NET or Java?

When launching a thread or a process in .NET or Java, is there a way to choose which processor or core it is launched on? How does the shared memory model work in such cases? ...

How to make Ruby or Python web sites to use multiple cores?

Even though Python and Ruby have one kernel thread per interpreter thread, they have a global interpreter lock (GIL) that is used to protect potentially shared data structures, so this inhibits multi-processor execution. Even though the portions in those languajes that are written in C or C++ can be free-threaded, that's not possible wit...

Multiple threads stuck in native calls (Java)

I have a problem with an application running on Fedora Core 6 with JDK 1.5.0_08. After some amount of uptime (usually some days) threads begin getting stuck in native methods. The threads are locked in something like this: "pool-2-thread-2571" prio=1 tid=0x08dd0b28 nid=0x319e waiting for monitor entry [0xb91fe000..0xb91ff7d4] at java....

Thread pool for executing arbitrary tasks with different priorities

I'm trying to come up with a design for a thread pool with a lot of design requirements for my job. This is a real problem for working software, and it's a difficult task. I have a working implementation but I'd like to throw this out to SO and see what interesting ideas people can come up with, so that I can compare to my implementatio...

Why doesn't JavaScript support multithreading?

Is it a deliberate design decision or a problem with our current day browsers which will be rectified in the coming versions? ...

Security implications of multi-threaded javascript

Reading through this question on multi-threaded javascript, I was wondering if there would be any security implications in allowing javascript to spawn mutliple threads. For example, would there be a risk of a malicious script repeatedly spawning thread after thread in an attempt to overwhelm the operating system or interpreter and trig...

File Access Strategy in a Multi-Threaded Environment (Web App)

I have a file which is an XML representation of some data that is taken from a Web service and cached locally within a Web Application. The idea being is that this data is very static, but just might change. So I have set it up to cache to a file, and stuck a monitor against it to check if it has been deleted. Once deleted, the file will...

Whats the best way to unit test from multiple threads?

Hi guys, this kind of follows on from another question of mine. Basically, once I have the code to access the file (will review the answers there in a minute) what would be the best way to test it? I am thinking create method which just spawns lots of BackgroundWorker's or something and tells them to all load/save the file, and test wi...

Instance constructor sets a static member, is it thread safe?

I am refactoring some code and am wondering about the use of a 'lock' in the instance constructor. public class MyClass { private static Int32 counter = 0; private Int32 myCount; public MyClass() { lock(this) { counter++; myCount = counter; } } } Please confirm Inst...

Thread-safe use of a singleton's members

I have a C# singleton class that multiple classes use. Is access through Instance to the Toggle() method thread-safe? If yes, by what assumptions, rules, etc. If no, why and how can I fix it? public class MyClass { private static readonly MyClass instance = new MyClass(); public static MyClass Instance { get { retur...

Best way to multi-thread?

What is the best way to multi-thread in c language? Very efficient or not CPU hog. Thanks ...

How to ensure that the same thread is used to execute code in IIS?

We have a third party dll that is used in our web service hosted in IIS6. The problem is that once this dll is loaded into memory, the exception AccessViolationException gets thrown if a thread different then the one that created it tries to execute any code within the dll. The worker process is multi threaded and each call to the web se...

Is there a good method in C# for throwing an exception on a given thread

The code that I want to write is like this: void MethodOnThreadA() { for (;;) { // Do stuff if (ErrorConditionMet) ThrowOnThread(threadB, new MyException(...)); } } void MethodOnThreadB() { try { for (;;) { // Do stuff } } catch (MyException ex)...

Silverlight DataBinding cross thread issue

I have an Image control with it's source bound to a property on an object(string url to an image). After making a service call, i update the data object with a new URL. The exception is thrown after it leaves my code, after invoking the PropertyChanged event. The data structure and the service logic are all done in a core dll that has...

Is there a way to ensure entire code block execution in a .NET thread?

In my C# program, I have a thread that represents a running test, which can be aborted by a click on a button labeled "Interrupt execution". In order for the thread (and therefore the test) to terminate in an elegant manner (and do some vital work beforehand), this button is enabled only in some well-defined moments, in which I catch Thr...

Multiple threads and performance on a single CPU.

Is here any performance benefit to using multiple threads on a computer with a single CPU that does not having hyperthreading? ...

Multi-Threaded splash screen in c#?

I know this question is all over the net, but I can't quite find what I am looking for and quite frankly this community seems more sophisticated than most I have seen. I want a splash screen to show while the application is loading. I have a form with a system tray control tied to it. I want the splash screen to display while this for...

How to make a WCF service STA (single-threaded)

I have a WCF service which includes UI components, which forces me to be in STA mode. How do I set the service behaviour to STA-mode? ...

How often do you use System.Component.BackgroundWorker in your UIs ? (if ever)

I am sure a responsive UI is something that everyone strives for and the reccomended way to do stuff is to use the BackgroundWorker for this. Do you find it easy to work with ? Do you use it often ? Or do you have your own frameworks for lengthy tasks and reporting process. I have found that I am using it quite a lot and even using it...