multithreading

How to mark .NET objects exposed to COM-interop as single threaded?

When defining a COM-visible class in C++ I can define the supported threading model in the header file (the threading(single) line): [ coclass, default(IComInterface), threading(single), vi_progid("Example.ComClass"), progid("Example.ComClass.1"), version(1.0), uuid("72861DF5-4C77-43ec-A4DC-ED04396F0CCD") ] ...

Haskell - Some questions about System.Process and mutithreading

I have a small numerical simulation in C (I had to do it in C to share it with my advisor) but I want to use a "haskell script" like thing to organize the simulation. The program accepts some command line arguments and spits some output I'd like to redirect to a file, so I did something like this: import Control.Monad import System.Pr...

Socket problem when using threading

Can someone please explain me why the following code doesn't work? using System; using System.Collections.Generic; using System.Text; using System.Net.Sockets; using System.Net; using System.Threading; namespace SocketThreadingTest { class Program { static void Main(string[] args) { Thread t = new Th...

Java Servlets threading model

I was wondering if anybody could explains me the threading model of Java Servlets? As I understood about that, there is only one instance of a servlet can be existed in the servlet container and if muliple threads happens to be waiting for that servlet, there requests are serialized in some manner. I don't know how that serialization pr...

What are immutable objects?

What is the relationship with thread-safety and immutable objects? Does it makes easier to share a single resource among multiple threads? If immutable objects are stateless, can they be pooled in a container like a J2EE container? thanks ...

Maximum queued elements in ThreadPool.QueueUserWorkItem

I set the max thread to 10. Then I added 22000 task using ThreadPool.QueueUserWorkItem. It is very likely that not all the 22000 task was completed after running the program. Is there a limitation how many task can be queued for avaiable threads? ...

To Mutex or Not To Mutex?

Do I need a mutex if I have only one reader and one writer? The reader takes the next command (food.front()) from the queue and executes a task based on the command. After the command is executed, it pops off the command. The writer to the queue pushes commands onto the queue (food.push()). Do I need a mutex? My reader (consumer) only e...

Problems launching an NSTimer from a secondary thread

I'm noticing in my code that when I try to start an NSTimer from a secondary thread, it doesn't work. I tried calling +[NSRunLoop currentRunLoop] just in case the problem was that the thread didn't have a run loop...but no dice. (Note that that was a shot in the dark. The docs said that would create a run loop, but perhaps there's other ...

Disabling Multithreading during runtime

Hi, I am wondering if Intel's processor provides instructions in their instruction set to turn on and off the multithreading or hyperthreading capability? Basically, I wanna know if an Operating System can control these feature via instructions somehow? Thank you so much Mareike ...

Designing Thread Class

I have a design question. Is it better to define separate classes for SENDING and RECEIVING. Or, is it better to define a single Thread class? I like the idea of a single Thread class because it is easier to share a queue which can be locked by mutex. Design Option #1 (Separate): mySendThread = new SendThread(); // Have thread properti...

Call back to delegate using the main thread rather than secondary thread?

I've defined a class called 'AsyncNetworkOperation', a subclass of NSOperation used to perform database queries in my app. My AsyncNetworkOperation class has a protocol, to be used by objects that initiate the AsyncNetworkOperation: @protocol AsyncNetworkOperationDelegate @optional - (void)operationAboutToFinish; @required - (void)opera...

How to spawn thread when defined function is set (sequentially dependent) and calling is spatially dependent

Hi. I apologize for my question being a bit confusing. So I have code written in python but also used H3D haptics platform. I'm trying to unload some of the processing of this one, very large thread so that I can log faster. I'm not sure how to write it since a function 'moveCursor' is already defined and later set to a specific number...

Update UI from multiple worker threads (.NET)

I have a pet project that I'm working on that has multiple worker threads. Outputting everything to the console is getting hard to follow, so I want to develop a UI that will have one output area per thread. I want to know the best way for the threads to send updates to the UI. I have two ideas: 1) Have each thread set a "DataUpdated" f...

Difficulties displaying the text in simple client/server chat program (current input gets displayed) - C

I am writing a chat program for my networking class and I have all the networking setup perfectly. My problem is if a client is currently writing a message and he receives a message from a different client then his current input gets displayed with the received message. For example if a client is writing a message "Hi there how are yo...

Pausing/stopping and starting/resuming Java TimerTask continuously?

Hi all I have one simple question regarding Java TimerTask. How do I pause/resume two TimerTask tasks based on a certain condition? For example I have two timers that run between each other. When a certain condition has been met inside the task of first timer, the first timer stops and starts the second timer, and the same thing happens...

Simple description of worker and I/O threads in .NET

It's very hard to find detailed but simple description of worker and I/O threads in .NET What's clear to me regarding this topic (but may not be technically precise): Worker threads are threads that should employ CPU for their work; I/O threads (also called "completion port threads") should employ device drivers for their work and ess...

Run backgrund process in different thread in Java

Hi, I am writing an application where user can add and remove other users as friends. My page has a list of diffrent users and each user is given with a button to add them in friend list. I am sending a AJAX request to Java servlet to add the selected user as a friend. I am showing alert message at UI to show the result of process. My ...

beginthread Vs CreateThread

What is the difference between CreateThread and beginthread APIs in Windows? Which one is preferrable for thread creation? ...

Why can't I access some library classes when I'm in a thread?

Why does the following require "bio" threads = (1..2).map do Thread.new do seqs = ["gattaca"] * 5 alignment = Bio::Alignment.new(seqs) end end threads.each {|th| th.join} ; nil give this error message? NameError: uninitialized constant Bio::Alignment from (irb):6 from (irb):10:in `join' from (irb):10 fro...

Patterns for PHP multi processes?

Which design pattern exist to realize the execution of some PHP processes and the collection of the results in one PHP process? Background: I do have many large trees (> 10000 entries) in PHP and have to run recursive checks on it. I want to reduce the absolute execution time. ...