multithreading

Can a C# thread really cache a value and ignore changes to that value on other threads?

This question is NOT about race-conditions, atomicity, or why you should use locks in your code. I already know about those. UPDATE: My question isn't "does weirdness with volatile memory exist" (i know it does), my question is "doesn't the .NET runtime abstract that away so you'll never see it". See http://www.yoda.arachsys.com/cshar...

Is there a 'standard' read/write lock implementation for ruby?

Does anyone know of an existing ruby implementation of a read/write lock - http://en.wikipedia.org/wiki/Readers-writer_lock? Preferably this would be in a popular library or some other implementation that's been used by enough people that it's fairly bulletproof at this point. ...

Thread specific data with webpy

I'm writing a little web app with webpy, and I'm wondering if anyone has any information on a little problem I'm having. I've written a little ORM system, and it seems to be working pretty well. Ideally I'd like to stitch it in with webpy, but it appears that just using it as is causes thread issues (DB connection is instantiated/access...

WPF Threading - Can someone explain what's going on here?

DISCLAIMER: The following code is not something I would ever use in a real application. I stumbled on this problem and would like to know what's happening under the hoods. Let's assume that for some crazy reason we had the following code... using (System.Net.WebClient webClient = new System.Net.WebClient()) { bool done = false; ...

OS Multi threading differences

I'm asking this question because i was investigating the Haiku OS (a BeOS descendant). The goal of the BeOS operating system was to create a desktop environment that handles multimedia well and is very responsive. They manage this by creating a kernel that has "pervasive multi threading". Other operating systems (linux, windows etc.) d...

Multithreaded code - force execution order

I have some code that will be accessed from two threads: class Timer{ public: void Start(){ start_ = clock_->GetCurrentTime(); running_ = true; } void Read(){ if(running_){ time_duration remaining = clock_->GetCurrentTime() - start_; Actions(remaining) } } private: void Actions...

What is the most frequent concurrency problem you've encountered in Java?

This is a poll of sorts about common concurrency problems in Java. An example might be the classic deadlock or race condition or perhaps EDT threading bugs in Swing. I'm interested both in a breadth of possible issues but also in what issues are most common. So, please leave one specific answer of a Java concurrency bug per comment an...

Destructor vs member function race

When I'm inside a destructor is it possible that some other thread will start executing object's member function? How to deal with this situation? ...

Thread safety of static blocks in Java

Let's say I have some Java code: public class SomeClass { static { private final double PI = 3.14; private final double SOME_CONSTANT = 5.76; private final double SOME_OTHER_CONSTANT = 756.33; } //rest of class } If a thread is instantiating an instance of SomeClass and is in the middle of initializi...

Java Threads: Specifying what should be executed in the run function

I have a DBAdmin class that connects to the database, and then some other classes such as Article, Category and so on, that perform certain queries to a database. I am using these classes in a Swing application to build a sort of small Intranet CMS application. Now, the Category class has a bunch of static methods such as addCategory, ...

Multithreading libraries for C#/.NET

I used mupltiple threads in a few programs, but still don't feel very comfortable about it. What multithreading libraries for C#/.NET are out there and which advantages does one have over the other? By multithreading libraries I mean everything which helps make programming with multiple threads easier. What .NET integratet (i.e. like ...

.NET: Asynchronous rollback due to Transaction timeout

In a C# project, I have a (volatile) transactional resource enlisted in a System.Transactions.Transaction. When a transaction timeout occurs, the rollback is executed in a worker thread: Obviously, the transaction uses a timer and calls a timer callback when the timer elapses (there is very little documentation from MS on this issue). Th...

.NET ThreadPool clarification - Available vs idle threads

Hi, I'm a little confused about one aspect of the .NET ThreadPool: namely, how you can tell how many of its 'Available' threads are idle ones waiting to be reused, and how many haven't yet been created. The summary for the GetAvailableThreads() method states that it: Retrieves the difference between the maximum number of thread p...

How can I set it up so that threads communicate they're complete with their task?

Conceptually, I would like to accomplish the following but have had trouble understand how to code it properly in Python: from threading import Thread for i in range(0,3): t = Thread(target=myfunction) t.start() # wait until threads have finished executing print 'complete!' ...

JTree gives ArrayIndexOutOfBoundsException?

I try to dynamically add nodes to a Java Swing JTree, and the user should be able to browse and to collapse hierarchy while nodes are constantly added. When I add a Thread.sleep(10) in my loop, it works fine; but this is a dirty hack... Here is the stripped down code that triggers this problem. Whenever I run this and doubleclick on the...

How can I get managed threads from Process.GetCurrentProcess().Threads

I can get a list of running threads from Process.GetCurrentProcess().Threads, but I need to know the managed name of threads started with Thread.Start. It isn't a property on the ProcessThread object though. Is there a way to get this information from a ProcessThread? ...

How can I enumerate all managed threads in C#?

Is it possible to enumerate all managed threads in C#? Visual Studio seems to be able to do this when you hit a break point while debugging. In the "Threads" window it shows a list of all running threads, including managed names. Does anyone know how it does this? ...

Are temporary tables thread-safe?

I'm using SQL Server 2000, and many of the stored procedures it use temp tables extensively. The database has a lot of traffic, and I'm concerned about the thread-safety of creating and dropping temp tables. Lets say I have a stored procedure which creates a few temp tables, it may even join temp tables to other temp tables, etc. And le...

Renaming Threads in Java

I am working on a project that is slowly getting larger and larger and the number of active threads used by many different processes is increasing. Lately, I have been taking a closer look at the running threads in the debugger and I have noticed that a lot of my third party libraries have given very poor names to their threads - Timer-0...

Spring JdbcTemplate and Threading

Is it safe to fork off a Thread to execute an insert using a JdbcTemplate in Swing. It's a logging event and as much as possible I don't want it to affect perceived performance. ...