multithreading

How could I get to know the resources occupied by a .NET thread?

Hi guys! I am developing a multi-thread application and one of my threads is somehow blocked by something and thus it will occupy some resource such as a file forever. Is there a way to find out which thread is being blocked and more important what resouce is being held by that thread? At last and as usual, thanks for your patience and...

Thread Question

I have method which create background thread to make some action. In this background thread I create object. But this object while creating in runtime give me an exception : The calling thread must be STA, because many UI components require this. I know that I must use Dispatcher to make reflect something to UI. But in this case I ...

NSThread running a class

Hi, Every the example I find on the internet (including Apple doc) sets the target to self like this : [NSThread detachNewThreadSelector:@selector(threadedTask) toTarget:self withObject:nil]; Since i would like to do a more complex task in background (involving multiple methods), I thought of creating a class Task called like this : ...

C threads question

Write program that has two threads one is reading numbers from the user and the other is printing them such that the first thread reads a new number only after it has been printed by the second thread. Declare one global varaible to use for reading and printing. #include <stdio.h> #include <pthread.h> #include <semaphore.h> sem_t m; vo...

problem with threads

I want to be done for 10 times, to scan the number and print it again. How can I do that? #include <stdio.h> #include <pthread.h> #include <semaphore.h> sem_t m; int n; void *readnumber(void *arg) { scanf("%d",&n); sem_post(&m); } void *writenumber(void *arg) { //int x =3; //while(x>0) //{ //x ...

Sockets, Threads and Services in android, how to make them work together ?

Hi all, I am facing a probleme with threads and sockets I cant figure it out, if someone can help me please i would really appreciate. There are the facts : I have a service class NetworkService, inside this class I have a Socket attribute. I would like it be at the state of connected for the whole lifecycle of the service. To conne...

how do i know how many clients are calling my WCF service function

i am writing a program to test WCF service performance in high concurrency circumstance. On client side, i start many threads to call a WCF service function which returns a long list of data object. On server side, in that function called by my client, i need to know the number of clients calling the function. For doing that, i set a ...

WCF MSMQ consumer thread count

What's the best way to configure the maximum number of threads that can pull messages from an MSMQ queue, using a netMsmqBinding in WCF? For example, say I have an MSMQ service for which I only want to have 2 (or 10, or whatever number of) worker threads pulling messages off at a time. ...

In a multithreaded app, would a multi-core or multiprocessor arrangement be better?

I've read a lot on this topic already both here (e.g., stackoverflow.com/questions/1713554/threads-processes-vs-multithreading-multi-core-multiprocessor-how-they-are or http://stackoverflow.com/questions/680684/multi-cpu-multi-core-and-hyper-thread) and elsewhere (e.g., ixbtlabs.com/articles2/cpu/rmmt-l2-cache.html or software.intel.com/...

java methods and race condition in a jsp/servlets application.

Hi. Suppose that I have a method called doSomething() and I want to use this method in a multithreaded application (each servlet inherits from HttpServlet).I'm wondering if it is possible that a race condition will occur in the following cases: doSomething() is not staic method and it writes values to a database. doSomething() is stat...

iPodMusicPlayer doesn't send notifications, if it is created in background

If iPodMusicPlayer is created in background, then I doesn't send notifications about playback state changes. Here is code: - (void)initMusicPlayer { musicPlayer = [MPMusicPlayerController iPodMusicPlayer]; NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter addObserver:self ...

What is the definition of a UI thread? Is there only one UI thread in a .NET application?

What is a UI thread? Is there only one UI thread in a .NET application? ...

Callback from another thread causes an exception

I'm trying to create a simple multiplayer game. There's a WorkerService which is supposed to handle all network communication and all interaction between this service and my Activities is done with AIDL. I think this is a standard approach - to enable two way interaction I use also an IWorkerCallback interface (also AIDL). The problem i...

Keeping track of threads when creating them recursively

I'm currently working on some code for a course. I can't post the code but I'm permitted to talk about some high level concepts that I'm struggling with and receive input on them. Basically the code is a recursive DFS on a undirected graph that I'm supposed to convert to a concurrent program. My professor already specified that I should ...

How about the Asp.net processes and threads and apppools?

Hi, as i understand, when i load a asp.net .aspx page on the (iis)server, it's processed via the w3p.exe process. But when iis gets multiple requests, are they all processed by the same w3p process? And does this process automaticly use all my processors and cores? And after that: when i start i new thread in my page, this thread still...

Is this function thread-safe?

Hello all,I am learning multi-threading and for the sake of understanding I have wriiten a small function using multithreading...it works fine.But I just want to know if that thread is safe to use,did I followed the correct rule. void CThreadingEx4Dlg::OnBnClickedOk() { //in thread1 100 elements are copied to myShiftArray(which is a...

Why is my BeginInvoke method not async?

Hi, In order to avoid freezing of GUI, I wanted to run method connecting to DB asynchronously. Therefore I have written this: DelegatLoginu dl = ConnectDB; IAsyncResult ar=dl.BeginInvoke(null, null); bool result = (bool)dl.EndInvoke(ar); But it is still freezing and I do not understand why - I though BeginInvok...

Optimizing a shared buffer in a producer/consumer multithreaded environment

I have some project where I have a single producer thread which writes events into a buffer, and an additional single consumer thread which takes events from the buffer. My goal is to optimize this thing for a single dual-core machine to achieve maximum throughput. Currently, I am using some simple lock-free ring buffer (lock-free is po...

Difference between Delegate.BeginInvoke and Thread.Start

Existing related questions here talk about differences between: Delegate.BeginInvoke and Control.BeginInvoke Control.BeginInvoke and Thread.Start But what are the differences between Delegate.BeginInvoke and Thread.Start? ...

c# run process without freezing my App's GUI

Hello, I want to start a process (calling another program), currently the external program takes time (it is normal)! but it freezes my GUI I saw allot of examples and I'm learning, it is hard to figure it out, trying to read and learn threading, but it is not that easy (at least for me) and good simple tutorial or code sample? cheers...