multithreading

creating new threads in a loop

I'm trying to understand why this code is not working. private static object _lock; public static void Main (string[] args) { Thread thread; _lock = new object(); foreach (int num in Enumerable.Range(0,5)) { thread = new Thread (() => print(num.ToString())); thread.Start(); ...

How to make sure your delegate(iphone, cocoa) is thread safe?

Hi I've seen a few examples of using delegate with multiple threads for async image loading with cocoa's URL loading system. I think the process goes like below. Thread 1 : give thread 2 an operation to perform, and a delegate which thread 2 will access upon completion. Thread 2 : upon completing the operation, calls a predefined se...

Java: "static class" or pass references around?

I'm part of a team designing the server for a client/server model naval warfare video game (University course). We have a fairly concrete (well, I think) system design, but there is one aspect that bothers me. The basic layout of the system is: Server [thread] (handles incoming connections) | Game [thread] (deals with game events in it...

TextBox custom ContextMenu in Style, multithreading error

In WPF application I use Textbox with custom style in which ContextMenu is overriden like this: <Style TargetType="{x:Type TextBox}"> <Setter Property="ContextMenu"> <ContextMenu> <MenuItem Header="Copy"/> </ContextMenu> </Setter> </Style> This works perfectly until I'll run window with TextBox in diffe...

How to find out the optimal amount of threads?

I'm planning to make a software with lot of peer to peer like network connections. Normally I would create an own thread for every connection to send and receive data, but in this case with 300-500+ connections it would mean continuously creating and destroying a lot of threads which would be a big overhead I guess. And making one thread...

Silverlight - fire of delayed action -

When I click on a button in Silverlight I want to run a method 2 seconds later once only for each time I click the button .. in the meantime the rest of the app keeps working .. obviously Thread.Sleep stops the whole UI .. how do I do this? ...

Read-only thread safety

What is mean term "Read-only thread safety" Can anyone post some code example? ...

Ruby threading pass control to main

Hi, I am programming an application in Ruby which creates a new thread for every new job. So this is like a queue manager, where I check how many threads can be started from a database. Now when a thread finishes, I want to call the method to start a new job (i.e. a new thread). I do not want to create nested threads, so is there any wa...

Custom Control Threading in WPF.

Hello EveryOne I am using WPF and I made some customecontrol just like a treeview, but this is the listtreeview so I am loading my all data into this treeview so it will take a much of time. so I am worry about how to implement threading to improve the perfomance... its urgent if u guys tell me. Thanks.. ...

A question on Java multi-threading

Hi, Assume the following class public class TestObject{ public void synchronized method1(){ //some 1000 lines of code } public void method2(){ //some 1000 lines of code } } Let's assume there are two threads accessing the same instance of TestObject class, let's call them t1 and t2. I want to know wha...

Handle a blocking function call in Python

Hi! I'm working with the Gnuradio framework. I handle flowgraphs I generate to send/receive signals. These flowgraphs initialize and start, but they don't return the control flow to my application: I imported time while time.time() < endtime: # invoke GRC flowgraph for 1st sequence if not seq1_sent: tb = se...

Will this code not result in a deadlock? Java Threads locking

So the thing is, I want to be able to do this with my class. object.lockAccess(); object.doSomething(); object.doAnotherThing(); object.doAnotherThingYet(); object.unlockAccess(); So the other thread will not be able to access my class methods while locked. Here is the implementation I did, I was wondering if someone got a better idea,...

Suggestions to Optimize Blocking Queue implementation

T BlockingQueue<T>::pop( ) { pthread_mutex_lock(&lock); if (list.empty( )) { pthread_cond_wait(&cond) ; } T temp = list.front( ); list.pop_front( ); pthread_mutex_unlock(&lock); return temp; } The above is the pop operation as defined for a templatized concurrent blocking qu...

How Java-Feature multithreading returning result ?

I am still learning about using Future and Callable in Java. Stumble into this question: Say I have class: TaskWorker implements Callable { public String id; public TaskWorker(String id) { this.id = id; } public Documents call() trows Exception { //Assume here, that Search and Doc are my own method to search and re...

How to track child process using strace?

I used strace to attach to a process briefly. The process created 90 threads. When I found the offending thread, I had to tediously search for the parent thread, then the grandparent thread, and so on all the way to the root process. Is there a trick or tool to quickly figure out which thread created another? Or better yet, print the tre...

How to have 2 Threads Talk To Each Other?

I'm currently making a IRC bot in Java (I know, there are frameworks out there) and I'm trying to have it connect to multiple servers. The problem I'm having with this is not the connecting part, I'm just running my Connect class in x amount of threads. Each thread will connect the bot to the server/port specified. Now my problem is that...

FastCGI on IIS7... multiple concurrent requests from same user session?

Caveat: I realize this is potentially a server configuration question, but I thought there might be a programmatic answer, which is why I am posting here... Running PHP on Apache, our users were able to issue multiple concurrent requests (from different tabs in the same browser, for example). Since moving to FastCGI under IIS, this is...

Problem waking up multiple threads using condition variable API in win32

Hi everyone, I have a problem in understanding how the winapi condition variables work. On the more specific side, what I want is a couple of threads waiting on some condition. Then I want to use the WakeAllConditionVariable() call to wake up all the threads so that they can do work. Besides the fact that i just want the threads starte...

WCF Event Hooks? Multithreading Trouble?

I am trying to come up with some tactics for hooking the connection event whenever an instance is created in my WCF server. I decorated my class like this: [ServiceBehavior( InstanceContextMode = InstanceContextMode.PerCall , ConcurrencyMode = ConcurrencyMode.Multiple , Namespace="http://mystuff/test" )] So I was wondering if there was...

QT: QFileSystemModel _q_fileSystemChanged slot is executed on the UI thread which contradicts documentation

Hello, My UI is using QTreeView with QFileSystemModel to be able to select folders and files. The documentation for QFileSystemModel says that file structure update is done on a seperate thread which would mean the UI would not be blocked. However, this is not the case for me and I can't figure out the discreptency and how other peopl...