multithreading

Threading and lambda expressions

What is the difference between the two piecees of code below. will there be any issues using the second one. Scenario 1 private void Log(Exception e) { ThreadPool.QueueUserWorkItem(new WaitCallback(Log), e); } private void Log(object obj) { Exception e = (Exception)obj; Logger.Log(e); } Scenario 2 private void Log(Excep...

nonatomic property in an NSOperation object (threaded environment), when to use it?

I'm still getting the hang of working in a threaded environment using NSOperation, and I'm interested in understand if using the 'nonatomic' property is even worthwhile if you're subclassing NSOperation? If your defaultQueue is set to 1, is the additional overhead of nonatomic worth it? Might it be needed if you're executing more than 1...

Standard Thread safe .Net Dictionary

MSDN points out that mutating access to the .NET Dictionary<K,V> type is not thread safe. Is there a standard thread safe version? Note: "No there is not" is a valid answer if it is true. In that cases (and it seem to be) I'll go off and do the lock thing. Almost Duplicate What’s the best way of implementing a thread-safe Dictionary...

Threading for distance vector which does not drop packets.

Hi I am doing my assignment in Network architecture 1, where I have to implement a distance vector routing at each node. At each node, I have a thread which listens for incoming DatagramPackets containing routing information from neighboring nodes only on a specific port. When a datagram arrives, the thread processes that datagram, an...

Do I have to run the delegate of an UIScrollView in another thread to prevent performance problems during scrolling?

I'm going to do some sophisticated things in the delegate's methods during scrolling. I'll also implement the dynamic preloading of contents, so that it's theoretically possible to scroll through a few hundret thousand images. But I fear, that every time I do the preloading action for the next big chunk in scrolling direction, the delega...

ArcMap and BackgroundWorkerThread

I read in here I should stick with STA threads while working inside ArcMap. I was using a normal BackgroudnWorker, and my code was running really slowly. I am trying to change it so that the worker creates an STA thread inside and gets it to run on the "heavy" stuff. My problem now is that after the 2nd thread is done working, all my co...

How to include own data in ExecutionContext

I know that when you run some method in parallel by calling BeginInvoke() or ThreadPool.QueueUserWorkItem(...) .NET framework is capturing ExecutionContext object that contains Code Access Security information and some other things. What I want, is to include in ExecutionContext some data that is needed by my parallel method, but must b...

If ANSI C++ doesn't support multithreading, how can unmanaged C++ apps be multithreaded?

I have heard that C++ offers no native support for multithreading. I assume that multithreaded C++ apps depended on managed code for multithreading; that is, for example, a Visual C++ app used MFC or .NET or something along those lines to provide multithreading capability. I further assume that some or all of those managed-code capabil...

Client Monitoring keylogger problem

First of all, the keylogger that i am developing is not at all for offensive and destructive purposes. :) I am developing a client monitoring application in C#.NET. Keylogging is one of the features in my application. Though i have developed the code for the keylogger, i have not been able to implement it properly in my application. Th...

when we use Semaphore in consumer and producer buffer

I am working on BoundedBuffer class in consumer and producer we want to use the Semaphore in that class we did that but there are an error in every use of acquire() the rerror is: unreported exception java.lang.InterruptedException; must be caught or declared to be thrown Here is the code: import java.util.concurrent.Semaphore; publi...

C# Threading and using AutoResetEvent

Hello, I have the following code in a class library. And I wait for a call back into my main application. I am making a DownloadStringAsync call so I have to wait a few seconds to get the callback after it has finished. I have a 3 of these calls to wait for, so in my main application I am using AutoResetEvent to wait all of them to fini...

Too many calls to mprotect

I am working on a parallel app (C, pthread). I traced the system calls because at some point I have bad parallel performances. My traces shown that my program calls mprotect() many many times ... enough to significantly slow down my program. I do allocate a lot of memory (with malloc()) but there is only a reasonable number of calls to ...

Handling more than 1024 file descriptors, in C on Linux

I am working on a threaded network server using epoll (edge triggered) and threads and I'm using httperf to benchmark my server. So far, it's performing really well or almost exactly at the rate the requests are being sent. Until the 1024 barrier, where everything slows down to around 30 requests/second. Running on Ubuntu 9.04 64-bit. ...

How can I return a response from a WCF call and then do more work?

I have a synchronous web service call that returns a message. I need to quickly return a message that basically says that order was received. I then need to spend a couple of minutes processing the order, but cannot block the service call for that long. So how can I return from the web service, and then do some more stuff? I'm guessi...

What is meant by: "Client side asynchronous frameworks"

I was looking at a job posting requesting a desired knowledge of: "Client side asynchronous frameworks". What do they mean by this with respect to Microsoft technologies, specifically .NET framework? ...

Simple threading in Python 2.6 using thread.start_new_thread()

I'm following a tutorial on simple threading. They give this example and when I try to use it I'm getting unintelligible errors from the interpreter. Can you please tell me why this isn't working? I'm on WinXP SP3 w/ Python 2.6 current import thread def myfunction(mystring,*args): print mystring if __name__ == '__main__': tr...

Can I launch a thread from a constructor?

Given the J5+ memory model (JSR-133) is the following code thread-safe and permissible? And if it's safe, is it acceptable in some situations? public final class BackgroundProcessor extends Object implements Runnable { public BackgroundProcessor(...) { super(); ... new Thread(this).start(); } public void run() { ...

C# multi-threading code review

Is it important that I lock around the queue? public abstract class ExpiringCache<TKey,TValue> : IDisposable { protected readonly object locker = new object(); protected readonly Dictionary<TKey, TValue> cache = new Dictionary<TKey, TValue>(); private readonly Queue<KeyValuePair<TKey, long>> queue = new Qu...

Multi-threaded algorithm for solving sudoku?

I have a homework assignment to write a multi-threaded sudoku solver, which finds all solutions to a given puzzle. I have previously written a very fast single-threaded backtracking sudoku solver, so I don't need any help with the sudoku solving aspect. My problem is probably related to not really grokking concurrency, but I don't se...

Monitor.Wait/Pulse race condition in a multithreaded server

I'm having a problem with interlocked Monitor.Wait and Monitor.Pulse in a multi-threaded TCP server. To demonstrate my issues, here is my server code: public class Server { TcpListener listener; Object sync; IHandler handler; bool running; public Server(IHandler handler, int port) { this.handler = handle...