multithreading

GC.Collect and multithreading in C#

I am using C# 3.5 and the reactive extension supporting TPL in C# version before 4. My application calls GC.Collect() in several places (yes, I know that I should not manually call this method but please leave this point alone for at least this question). Before I put multithreading implementation in, it works fine. GC.Collect() is call...

Android: Multithreading-Bluetooth SPP/RFCOMM-How to keep my BluetoothSocket and OutputStream active when changing Activities

I am pretty new to Android and very new to Multithreading. I am writing an android application that contains multiple activities that implement onClickListners which sends a Bluetooth message on button click to . I have successfully been able to connect and keep my BluetoothSocket and OutputStream open while in one activity. I do not do...

Major slowdown using NSInvocationOperation (NSOperation) with NSOperationQueue on iOS 4 (iPhone)

I have a lengthy operation O that is called through a NSInvocationOperation, itself scheduled by adding it to a NSOperationQueue so that it runs asynchronously. That lengthy operation O is invoked in two different cases in my app. In case A, operation O is invoked as a result of tapping some widget in some view. As soon as the widget is...

ThreadPool.QueueUserWorkItem and asynchronous programming

Hello All I have written a sample program below. class Program { static int x = 2; static void Main(string[] args) { Console.WriteLine("Thread ID {0} and Main Called!", Thread.CurrentThread.ManagedThreadId); ThreadPool.QueueUserWorkItem(Count, args); ThreadPool.QueueUse...

How to make ProgressDialog non-stop loading circle when I am loading a list of photos ?

Hi, I am downloading an array of photos from the net and showing a ProgressDialog with a loading circle. But the loading circle will be lag / hang while the process is not finish. How to make the loading running smoothly? Thanks. ...

Why .net Threadpool is used only for short time span tasks?

I've read at many places that .net Threadpool is meant for short time span tasks (may be not more than 3secs). In all these mentioning I've not found a concrete reason why it should be not be used. Even some people said that it leads to nasty results if we use for long time tasks and also leads to deadlocks. Can somebody explain it in...

Does an asynchronous call require an extra thread in the current process or use another thread in a thread pool?

I'm referring to this answer where it says it's not required, there are few specific assumptions though. That question is general. I'm using C# Asynchronous process is doing nothing but just calling an external API and waiting for the reply. ...

Is it considered acceptable to not call Dispose() on a TPL Task object?

I want to trigger a task to run on a background thread. I don't want to wait on the tasks completion. In .net 3.5 I would have done this: ThreadPool.QueueUserWorkItem(d => { DoSomething(); }); In .net 4 the TPL is the suggested way. The common pattern I have seen recommended is: Task.Factory.StartNew(() => { DoSomething(); }); How...

java swing thread problem

In my java swing application am having a Jframe and Jlabel for displaying current time. here am using a thread for displaying time in jlablel which is added to the frame.my doubt is that when i dispose the jframe what will happen to the thread whether its running or stopped. ...

How to get stack trace of a thread

I have a multithreaded application. Several messages are coming to the application and are processed in separated threads. For this I am using classes ThreadPoolExecutor and FutureTask from package java.util.concurrent. Occasionally I have some deadlocks in the application. When a deadlock occurs I want to interrupt the blocking thread ...

Backgroundworker and TPL's Task have the same ManagedThreadID?

I have a Backgroundworker whose purpose is to run jobs sequentially in the background. Now one job is implemented in multithreading way. That mean, the Backgroundworker will create several threads. I use Task Parallel Library so I use the Task.Factory.StartNew to create multiple Tasks. After the tasks are run, the Backgroundworker waits...

What is the difference between lock and Mutex?

What is the difference between lock and Mutex? Why can't they be used interchangeably? ...

Is it possible to using WebBrowser in a Thread ? (Delphi)

Hello , I'm using WebBrowser control to fill a web page . is it possible to using WB inside a thread ? Thank you ...

can a blocked java thread's method be executed by another thread?

was planning to create a server thread with a login (accepts new clients and creates threads that would handle them) and logout methods. login method will be blocked by socket.accept() method to wait for clients. would other clients who want to logout be able to call the logout method on the server thread, if the server thread is blocked...

CUDA: Stop all other threads

Hi, I have a problem that is seemingly just solvable by enumerating all possible solutions and then finding the best. In order to do so, I devised a backtracking algorithm that enumerates and stores the best solution if found. It works fine so far. Now, I wanted to port this algorithm to CUDA. Therefore, I created a procedure that gene...

why should we avoid lock(this)?

Possible Duplicate: Why is lock(this) {} bad? In C# to make a critical region thread safe we can use lock() statement. The lock statement takes an object. What is wrong if we pass this to the lock statement? ...

python threads - how do "condition.wait" and "condition.notifyAll" work

Hi, I have the following "consumer" code: .... while 1: time.sleep(self.sleeptime) cond.acquire() #acquire the lock print currentThread(), "lock acquired" while itemq.isEmpty(): cond.wait() itemq.consume() print currentThread(),"Consumed One Item" cond.rel...

Inter-process lock

I am writing a system for automatically recalculating the results of costly methods, and then storing them in a cache. The cache may be distributed, meaning (obviously) multiple processes can access it. On the first invocation of the method to cache the result for, I want to spawn a thread that will periodically recalculate the result o...

multithreading and classes?

Here is the issue that I'm having with multithreading. The proc needs to be static which means the only way I see that 2 threads can communicate and share data is through the global scope. This does not seem very clean nor does it feel very OO. I know I can create a static proc function in a class but that's still static. What I'd like ...

How to limit the number of threads created for an asynchronous Seq.map operation in F#?

The current setup goes something like this array |> Seq.map (fun item -> async { return f item}) |> Async.Parallel |> Async.RunSynchronously The problem is, this tends to create too many threads and crash the application periodically. How to limit the number of threads in this case (to, say, Environment.ProcessorCount)? ...