multithreading

Multi-threading Problem in Java: How to clear last element in a list when update method is no longer called?

I have this problem in a project I'm working on: I have a list of elements sent through a server, I have a local copy of that list each time the server calls my client's update method. The update method itself checks if the newly sent list is identical to the local copy, if not, modify the local copy. This means that if on the server, ...

Threading Synchronizing

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace ThreadDemo { class Program { static public List<int> temp = new List<int >(); static public List<Thread> worker = new List<Thread>(); static public List<List<int>> Temporary = new Lis...

Any good threads related job-interview question?

When interviewing graduates I usually ask them questions about data structures, algorithms and complexity theory. I would really like to ask a question that will enable them to show their familiarity with multi-threaded concepts, without dwelling into language specific issues. Any good questions? The only question I could think of is ho...

How can I share data between threads?

I want to share data between two threads. How can we do that? Give some simple program. ...

Is it rude to trigger OnNext from different threads in Reactive Extensions (Rx)?

When implementing IObserver yourself, you know how well you would cope with a situation where OnNext is invoked from different threads, concurrently or sequentially, but what are the expectations of the built in Reactive Extension primitives when it comes to this? Will BufferWithTime, for example, cope with OnNext being invoked from mult...

Backgroundworker thread displays error message on leaving page

I am currently developing a Wizard in VS2010 C#. The second to last page is a progress page with a progress bar. The work being performed takes a long time. So I have created a Backgroundworker thread and do the lengthy operation in DoWork. I update the progress bar using the ProgressChanged event. The code for the lengthy process is in ...

is multithreading is possible in a simple java server using udp connectionless protocol? pls give an example!!

is multi-threading is possible in a simple java server using udp connectionless protocol? pls give an example!! ...

Unit Testing results that are retrieved by a processed Thread

I have a unit test in which I mock (with moq) an object and let it verify if it executed a method properly. This method is being executed in a Thread that I create in my SUT (System under Test). When I want to do VerifyAll() on the Mock it could happen that the Thread is still running and that it isn't finished yet executing the method -...

What collection supports multiple simultaneous insertions?

Hi, We are developing a Java application with several worker threads. These threads will have to deliver a lot of computation results to our UI thread. The order in which the results are delivered does not matter. Right now, all threads simply push their results onto a synchronized Stack - but this means that every thread must wait for...

How to traverse a binary tree in a thread safe way?

I need a way to traverse a binary tree, using multiple threads and store elements that matches a criteria into a list. How do I do that, in a thread safe way? ...

gtk+ multithreading image loading

Hello, Where can i find example of gtk+ multithreading image loading? Thank you ...

How to run concurrent threads in perl?

The following does not appear to run in concurrent threads as I expected, but rather each process blocks until it is complete: my @arr = (1,2,3,4); foreach (@arr) { threads->new(\&doSomething, $_)->join; } sub doSomething { my $thread = shift; print "thread $thread\n"; sleep(5); } In other words, it appears to be execu...

how to restart a thread in android?

hi there! in my android app i have an ui-update-thread that keeps all my views up-to-date. protected Thread UIUpdateThread = new Thread() { @Override public void run() { while(true) { query_some_data_from_service(); // gets some "fresh" data from a service UIUpdateHandler.sendEmptyMessage(0); // will update all ui eleme...

What scenarios constitute a Non-Default Execution Context in .Net?

WaitHandle.WaitOne() has an ExitContext option to allow for temporary release of a resource lock before holding for another. This is useful in some cases where dead-lock or thread starvation may occur. The msdn documentaiton talks about a dondefault context. They only refer to examples which constitutes being in a nondefault context i...

Waiting on event with Twisted and PB

I have a python app that uses multiple threads and I am curious about the best way to wait for something in python without burning cpu or locking the GIL. my app uses twisted and I spawn a thread to run a long operation so I do not stomp on the reactor thread. This long operation also spawns some threads using twisted's deferToThread t...

Wait for one of several threads

I have a java application where the main-thread starts 2 other threads. If one of these threads terminates, the main-thread may start another thread depending on the result of the terminated thread. Example: The main-thread creates 2 threads: A and B. Thread A will load a picture and thread B will load another picture. If A terminates a...

UIWebView as part of a UITableViewCell: leading to crash because of a thread lock

Hi everybody, I'm trying to add a UIWebView as a subview of a UITableViewCell in order to display some data formatted with MIMEType 'application/xhtml+xml'. Even just initializing the UIWebView as described in the following code leads the application to crash! - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath...

My app mem usage is growing using pthread.

Hi, I am using C language and Linux as my programming platform. In my user-space application. I used pthread to create a thread. int main() { pthread_t thread1, thread2; pthread_create( &thread1, NULL, fthread1, NULL ); pthread_create( &thread2, NULL, fthread2, NULL ); return 0; } void *fthread1( void *ptr ) { /* do s...

Why doesn't this thread example work? It all wait()'s

The code below is to emulate a robotics simulator I'm working with. I'm not entirely sure why this doesn't work - I'm not very familiar with threads and even though I've tried reading plenty today, I don't seem to be making progress. The problem is that once pauseDistanceSensor() is called, it never wakes up. import java.util.Random; p...

Multi-Threading on different instances of same object in Java

I've learned that every class byte code is been loaded to the memory once for each class loader, thus when a thread is executing the byte code of some method, and another thread comes along? 1 thread -> 1 instance - of class Foo == no problem. X threads -> 1 instance - of class Foo == need to be handled this is clear. X threads ->...