multithreading

j2me no of threads

I am developing a j2me map based application. Screen is divided into a grid of images and I have to request these images from a server. This can be threaded. What is the maximum no of threads that I can spawn in a j2me midlet? Is there a way to arrive at this no? ...

Pthread and wait conditions

I'm learning pthread and wait conditions. As far as I can tell a typical waiting thread is like this: pthread_mutex_lock(&m); while(!condition) pthread_cond_wait(&cond, &m); // Thread stuff here pthread_mutex_unlock(&m); What I can't understand is why the line while(!condition) is necessary even if I use pthread_cond_signal() to ...

Compact Framework 2.0: How can I stop a thread when an object is dispose?

Hello! I have this code: Thread t = new Thread(() => UpdateImage(origin)); t.Name = "UpdateImageThread"; t.Start(); This code is created on a Custom Control. I want to stop this thread (if it's running) when the object is going to be dispose. This custom control has the following method: void IDisposable.Dispose() { /* My own co...

can a long running for loop be broken into multiple thread slices in c#

I have a For-loop which takes a very long time to execute,I am creating a new row in loop and adding it to data table. what i want is handle this long running process on multiple threads.For eg :- for 2000 lines have one for loop on one thread,another 2000 lines on another thread and so on. Please provide some source code to achieve th...

Java Thread Shared Object Synchronization Issue

I'm having issues with Synchronized not behaving the way i expect, i tried using volatile keyword also: Shared Object: public class ThreadValue { private String caller; private String value; public ThreadValue( String caller, String value ) { this.value = value; this.caller = caller; } public synchronized String getValue() { ...

Possible - cancel user control rendering if not loaded in x seconds?

This is probably a lark, but for the recaptcha control as it sometimes takes a long time to render, is this possible? If it takes more than say 5 seconds to render, I'd like to stop the rendering of the object and display my own captcha. I'd start a timer on page load and if 5 seconds has elapsed, in some event in the recaptcha con...

C++: Multi threading and reference counting

Currently ive got some reference counted classes using the following: class RefCounted { public: void IncRef() { ++refCnt; } void DecRef() { if(!--refCnt)delete this; } protected: RefCounted():refCnt(0){} private: unsigned refCnt; //not implemented RefCounted(RefCounted&); RefC...

Running Async IO threads to completion in same order as received

Sorry, I am very new to all this multithreading stuff... I'm working on a client/server app and I'm going to use System.Net.Sockets.NetworkStream's Async IO methods. I'm aware that after calling BeginRead, the system will start calling my callback every time it receives data. The callback could take a significant amount of time to co...

Why was the 'thread' module renamed to '_thread' in Python 3.x?

Python 3.x renamed the low-level module 'thread' to '_thread' -- I don't see why in the documentation. Does anyone know? ...

Thread.Interrupt to stop long sleep at app shutdown - Is there a better approach

I'm having a small background thread which runs for the applications lifetime - however when the application is shutdown, the thread should exit gracefully. The problem is that the thread runs some code at an interval of 15 minutes - which means it sleeps ALOT. Now in order to get it out of sleep, I toss an interrupt at it - my questio...

New Thread is still blocking UI-Thread

Hi, when a button is clicked i start a seperate thead which is population a grid and does something with a webbrowser-control. But when the button is click the new thread seems not to be seperate, cause the UI is freezing until the new thread is done. Here the code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As S...

Scoped DataContext intermittently raises ExecuteReader error

Our application follows the approach of maintaining a DataContext per Thread/HttpContext, using the DataContextFactory class outlined by Rick Strahl on his blog, including the amendment to the Key mentioned by Richard (use of type.AssemblyQualifiedName). The solution appeared sound (although in most cases a different approach may be bet...

Alternative to BackgroundWorker that accepts more than one argument?

The BackgroundWorker object allows us to pass a single argument into the DoWorkEventHandler. // setup/init: BackgroundWorker endCallWorker = new BackgroundWorker(); endCallWorker.DoWork += new DoWorkEventHandler(EndCallWorker_DoWork); ... endCallWorker.RunWorkerAsync(userName); // the handler: private void EndCallWorker_DoWork(object ...

Long-running thread process under ASP.NET + WCF

Duplicate This is a close duplicate of Dealing with a longer running process in WCF. Please considering posting your answer to that one instead of this. Original Question I'm implementing the business layer of an application that must run some background processes at scheduled times. The business layer is made up of several WCF services...

Objective-C run loop to stop and re-start method?

I used to think I was a reasonably intelligent person. apple's "threading programming guide", has shattered my ego sustaining self deception. I have a method I want to run repeatedly on a secondary thread, in the example below I've called this doStuff: I want to be able to repeatedly stop and start the repeated calling of this method. ...

How to debug a deadlock?

Other than that I don't know if I can reproduce it now that it's happened (I've been using this particular application for a week or two now without issue), assuming that I'm running my application in the VS debugger, how should I go about debugging a deadlock after it's happened? I thought I might be able to get at call stacks if I paus...

x86 equivalent for LWARX and STWCX

I'm looking for an equivalent of LWARX and STWCX (as found on the PowerPC processors) or a way to implement similar functionality on the x86 platform. Also, where would be the best place to find out about such things (i.e. good articles/web sites/forums for lock/wait-free programing). Edit I think I might need to give more details as ...

Why must UI elements always be created/updated from the UI thread?

The title says it all: Why must UI elements always be created/updated from the UI thread? In (almost?) all programming languages UI elements may be safely accessed/modified only from the UI thread. I understand that it's a standard concurrent access and synchronization problem, but is it really necessary? Is this behaviour imposed by th...

how to make User Controls to run on their own thread

how can i make a user control to run on its own thread ? e.g. by following code in a user control , coz user control uses main app thread it make main thread to sleep Thread.Sleep(TimeSpan.FromMinutes(2)); ...

Is the iPhone NSOperationQueue implementation bugged?

In MacOS Leopard versions prior to 10.5.7, NSOperationQueue was famously buggy. Does anyone know if this bug applies to the iPhone OS (which also features this API), and if so to which versions? ...