multithreading

What difference it makes when I set python thread as a Deamon

What difference it makes when I set python thread as a Deamon, using thread.setDaemon(True) ? ...

Multithreaded Engine Windowed random slowdown

We have a task based multithreaded engine set up where a scheduler passes the task to the threads lock-free queue. The engine is in C++ with DirectX for the rendering and we are using boost::thread for creating the threads. When in windowed mode, it randomly slows down for a second or so and then speeds back up. It seems that it's someth...

Ruby Threads (Rake) for FTP

I have a rake task that uploads a list of files via ftp. Copying without threading works fine, but it would be faster if I could do multiple concurrent uploads. (I'm new to ruby and multithreading, so no surprise it didn't work right off the bat.) I have: files.each_slice(files.length / max_threads) do |file_set| threads << Thread....

Boost Jam Not Producing Thread Library on Windows

I downloaded the latest Boost Jam binary from SourceForge and I'm using the command: bjam toolset=gcc --build-type=complete stage I've installed Cygwin along with the GCC compiler. While the command produces a stage/lib directory, I cannot find the thread library that I'm using in Linux. Boost Jam takes a while to run, so there coul...

SwitchToThread/Thread.Yield vs. Thread.Sleep(0) vs. Thead.Sleep(1)

I am trying to write the ultimate "Yield" method to yield the current time slice to other threads. So far I have found that there are several different ways to make the thread yield its allocated time slice. I just want to make sure I am interpreting them correctly since the documentation is not very clear. So, from what I have read on s...

How to test visibility of values between threads

What is the best way to test value visibility between threads? class X { private volatile Object ref; public Object getRef() { return ref; } public void setRef(Object newRef) { this.ref = newRef; } } The class X exposes a reference to the ref object. If concurrent threads read and and write the object reference every Thread...

How to manage M threads (1 per task) ensuring only N threads at the same time. With N < M. In Java

I have a queue of task in java. This queue is in a table in the DB. I need to: 1 thread per task only No more than N threads running at the same time. This is because the threads have DB interaction and I don't want have a bunch of DB connections opened. I think I could do something like: final Semaphore semaphore = new Semaphore(N...

ASP.NET: Does every HttpRequest get its own thread?

In ASP.NET, does every HttpRequest get its own thread? Update - To clarify, I'm asking specifically about incoming requests. ...

Java Executors: how can I stop submitted tasks?

I have submitted a task using executors and I need it to stop after some time (e.g. 5 minutes). I have tried doing like this: for (Future<?> fut : e.invokeAll(tasks, 300, TimeUnit.SECONDS)) { try { fut.get(); } catch (CancellationException ex) { fut.cancel(true); tasks.clea...

Asynchronous methods and asynchronous delegates

C# 3.0 in a nutshell says asynchronous methods and asynchronous delegates looks similar but the behavior is very different. Here is what the book says about both. Asynchronous methods Rarely or never blocks any thread. Begin method may not immediately return to the caller. An agreed protocol with no C# language support. Asynchrono...

Running threads in vb.net

I have an application in which I am running a separate thread. Dim thread As New System.Threading.Thread(AddressOf Main) thread.Start() However, the thread makes reference to an textbox named Output, and it generates this error upon execution: System.InvalidOperationException was unhandled Message="Cross-thread operation not valid:...

A confusion about parallel_accumulate in C++ Concurrency in action

In the following example (Chapter 2), Anthony Williams is trying to parallelize the standard accumulate function. my question is why is he doing this: unsigned long const max_threads=(length+min_per_thread-1)/min_per_thread; why add length and subtract 1? why not just: unsigned long const max_threads=length/min_per_thread; ....

Is this thread safe?

private static bool close_thread_running = false; public static void StartBrowserCleaning() { lock (close_thread_running) { if (close_thread_running) return; close_thread_running = true; } Thread thread = new Thread(new ThreadStart(delegate() { while (true) { lock (close_thread_running) { ...

Can pthreads only share global resources?

I'm trying to share a structure between two threads that is not a global variable. The variable itself is instantiated on the stack in the main function, then its pointer is passed as the parameter to both threads on the start up of both threads. What I'm finding is that when I change the value of a member of that structure that change...

Stopping embedded Python

I'm embedding Python interpreter to a C program. However, it might happen that while running some python script via PyRun_SimpleString() will run into infinite loop or execute for too long. Consider PyRun_SimpleString("while 1: pass"); In preventing the main program to block I thought I could run the interpreter in a thread. How do I st...

How to pass data between threads?

What are ways to pass data between threads in .NET? There are two things I can currently think of: Membervariables, e.g. using the producer-consumer-queue pattern. Using the ParameterizedThreadStart delegate when starting the the thread. (Only works once, not good for long running background worker threads). What facitlites does the...

Thread Control.Invoke

I have a function public void ShowAllFly() { cbFly.Items.Clear(); cbFly.Items.Add("Uçuş Seçiniz..."); dsFlyTableAdapters.tblFlyTableAdapter _t=new KTHY.dsFlyTableAdapters.tblFlyTableAdapter(); dsFly _mds = new dsFly(); _mds.EnforceConstraints = false; ds...

Visual Studio step into doesn't return

I have a multi threaded application. It also uses some unmanaged code, an ODBC driver. If I am in a specific thread, sometimes I hit step over, F10, however it doesn't stop on the next line, the program runs as though I have hit F5 to continue. Any ideas why this is? Update 1 When I say the program runs, I mean the thread I am in. I ha...

Launching a thread from a loop and passing Loop ID

I just started playing around with threading today and I ran into something that I dont understand. public void Main() { int maxValue = 5; for (int ID = 0; ID < maxValue; ID++) { temp(ID); } } public void temp(int i) { MessageBox.Show(i.ToString()); } As basic as it gets which works fine, but when I try t...

Is there a programmatic way to check stack corruption

I am working with a multithreaded embedded application. Each thread is allocated stack sizes based on its functionality. Recently we found that one of the thread corrupted the stack by defining a array of local variables that was more than the stack size. The OS is uItron. My solution, I registered a timer for 10 mS, and this timer will...