multithreading

Multi-Threading, HttpContext, Long Running Task?

Hi, I got started with threads Thread.Start() recently and Long Running Tasks and noticed several request related issues. EDIT What would you suggest to provide the user a feedback while the job is being processed, make efficient use of the thread pool and make use of HttpContext if possible? ...

Seeking Clarity on Java ScheduledExecutorService and FutureTask

I'm just starting to look into Futures and the ScheduledExecutorService in Java, and I'm wondering why my Callable isn't running on the schedule I've indicated. In this sample code, the callable runs once, but the app never completes, nor does the task run again, which is what I expected to happen (I'm sure the problem is with my expecta...

Publishing Concurrent Objects

I'm interested in techniques people use to publish information and changes to data structures that are being shared across multiple threads without losing much concurrency. In my personal experience I come across the single writer/multiple readers quite often, where a single thread is updating an object, but multiple threads are reading ...

Loadtesting vs Threading

i am running iis 7 with .net 3.5 sp1 Can anyone tell me if this is thread safe since it keeps on failing under high load of users private static void addQueryStringParameters(XElement inputs) { NameValueCollection qs = HttpContext.Current.Request.QueryString; XElement queryStringParameters = new XElement("QueryStringParameters...

Managing a view while another process runs on iPhone

Hello, I am having a bit of a problem here, I am let the user upload some video to the server however I am having some difficulties managing a view that I am using to illustrate its progress, I know why the problem is happening and i found a way around it (sort of) here my problem So if one tries to make some code that looks something ...

How to effectively log asynchronously?

I am using Enterprise Library 4 on one of my projects for logging (and other purposes). I've noticed that there is some cost to the logging that I am doing that I can mitigate by doing the logging on a separate thread. The way I am doing this now is that I create a LogEntry object and then I call BeginInvoke on a delegate that calls Lo...

Multithreaded JDBC

Architecturally what is the best way to handle JDBC with multiple threads? I have many threads concurrently accessing the database. With a single connection and statement I get the following error message: org.postgresql.util.PSQLException: This ResultSet is closed. Should I use multiple connections, multiple statements or is there a...

Can an objective-C NSThread access global variables?

Ok, basically I have a run loop going in my application every second or two, while at the same time I have another thread going that is looping through the listenForPackets method; broadcastMessage is only initiated when another action method takes place. The important part of this question is that when the listener thread is running sep...

.NET multi-threaded variable access

I have an application with 4 threads. (GUI, Controller, Producer, Consumer) The GUI is self-explanatory. The controller starts the producer and consumer threads after some intial setup. The producer creates items and places them in a free slot in a "ring buffer" The consumer takes items from the "ring buffer" and writes them to disk....

Do I need to EnterWriteLock when using AddHandler?

When using a ReadWriteLockSlim for multi-threading support, do I need to EnterWriteLock when using AddHandler? Here are two examples to help illustrate my point: AddHandler ClassInstance.Event, New EventHandler(AddressOf Me.Method) -or- Me.ReaderWriterLockSlimInstance.EnterWriteLock() AddHandler ClassInstance.Event, New EventHan...

MFC: troubleshooting on which thread is responsible for causing a crash

I currently have my project running two separate threads (one for MFC operations, like views/formviews, application window, etc., and one for an infinite while loop in its main function). However, for certain situations, when I run my program in debug mode, I have noticed that one of the threads' exit status was a 1 (in other words, it r...

Make a recursive method pause in every recurse and continue with click

Hi! I have a recursive method that changes the value of a variable in every recursion, then it shows that value on the JPanel, and then I would like to pause (here is my problem) until I click (it pauses in every new recurse). Then when I click this method continues to do the next recursion. The following code is just the structure of...

Hooking thread exit

Is there a way for me to hook the exit of managed threads (i.e. run some code on a thread, just before it exits?) I've developed a mechanism for hooking thread exit that works for some threads. Step 1: develop a 'hook' STA COM class that takes a callback function and calls it in its destructor. Step 2: create a ThreadStatic instance of ...

Memory barriers in userspace? (Linux, x86-64)

It is easy to set memory barriers on the kernel side: the macros mb, wmb, rmb, etc. are always in place thanks to the Linux kernel headers. How to accomplish this on the user side? ...

.NET Terminating Threads in an orderly fashion

Currently, I have a RingBuffer which is run by a producer and a consumer thread. In looking for a method of terminating them orderly, I thought I'd use a flag to indicate when the producer had finished and then check that flag in my consumer along with the number of ring buffer slots that need to be written. If the producer has finishe...

Should I use thread local storage for variables that only exist in a {class,method}?

I am implementing a relatively simple thread pool with Python's Queue.Queue class. I have one producer class that contains the Queue instance along with some convenience methods, along with a consumer class that subclasses threading.Thread. I instantiate that object for every thread I want in my pool ("worker threads," I think they're ...

Python: is os.read() / os.write() on an os.pipe() threadsafe?

Hello! Consider: pipe_read, pipe_write = os.pipe() Now, I would like to know two things: (1) I have two threads. If I guarantee that only one is reading os.read(pipe_read,n) and the other is only writing os.write(pipe_write), will I have any problem, even if the two threads do it simultaneously? Will I get all data that was written ...

Visual C++ 2008 Boost Problem

Hey I'm using the C++ Communication Services Framework, which uses the Boost's Thread library. I'm compiling one of their test projects (CSF's) and i'm getting a huge errors The errors are in the Boost Bind library in file bind/mem_fn_template.hpp EDIT: I installed Boost through the Boost installers provided by BoostPro Here are few ...

Running a socket stream in a thread

I have an application that opens a connection with 2 sockets (in and out) and I want to have them working in a thread. The reason that I want them to be in a separate thread is that I don't want my application to freeze when I receive data, and this can happen anytime as long as the application is running. Currently I have a class that...

What are the Python thread + Unix signals semantics?

What are the rules surrounding Python threads and how Unix signals are handled? Is KeyboardInterrupt, which is triggered by SIGINT but handled internally by the Python runtime, handled differently? ...