Hello i wanna do apliacation which every 1 second call function or do something else.
I have this code which is not working can you tell what is wrong?
public class App5_Thread extends Activity implements Runnable {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInsta...
I use pthread_create to create several child threads. At a time, the main thread wants to kill all child threads or there will be segment falut. Which function should I use to finish that? I searched the answer from google and got function like pthread_kill. But I did not know which signal should I send to the child thread to kill them. ...
What is most apropriate mutex alg in C#/.NET for this kind of task.
many reads
few incremental changes (up to 3 in "go forward" state machine )
very low collision probability (does collision probability matter?).
I was thinking about simple lock or ReaderWriterLockSlim , but I am not sure which one to choose and if there is somethi...
I have a Windows service that has a number of threads that all need to be stopped before the service stops. I'm using this model for stopping my threads and signalling that they have been stopped:
ThreadPool.QueueUserWorkItem(new WaitCallback(delegate
{
Thread1Running = true;
try
{
while (running)
{
...
Update: As Brian pointed out, my original idea did indeed have a concurrency issue. This was somewhat obscured by the signature of the ConcurrentDictionary<TKey, TValue>.AddOrUpdate method, which can lull a lazy thinker (like myself) into believing that everything--the set add as well as the queue push--will somehow happen all at once, a...
I have a WPF application that kicks off 3 threads and needs to wait for them to finish. I have read many posts here that deal with this but none seem to address the situation where the thread code calls Dispatcher.Invoke or Dispatcher.BeginInvoke. If I use the thread's Join() method or a ManualResetEvent, the thread blocks on the Invoke ...
There should be an error/omission in the next code but I can't see where mostly because I've never used threads. Can someone please find what I'm missing?
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Timer;
import java.util.TimerTask;
imp...
Hello,
I have multiple ListActivity(s) with a custom ArrayAdapter. I have to load an XML file from the Web, and the user moves to a new activity by selecting a list item.
What is best practice for:
Displaying a loading indication to the user.
Threading the networking stuff so that the user can cancel the loading of the data if need b...
The classic advice in multithreading programing is to do processor heavy work on a background thread and return the result to the UI thread for minor processing (update a label, etc). What if generating the WPF element itself is the operation which is expensive?
I'm working with a third party library which generates some intense elemen...
Next is a simple semaphore implementation.
public class Semaphore {
private boolean signal = false;
public synchronized void take() {
this.signal = true;
this.notify();
}
public synchronized void release() throws InterruptedException {
while (!this.signal) wait();
this.signal = false;
}
}
Is it true, that by c...
I have a thread in java/Android like this:
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
update_i();
}
};
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
Thread myThread = new Th...
I have a web service that has ~1k request threads running simultaneously on average. These threads access data from a cache (currently on ehcache.) When the entries in the cache expire, the thread that hits the expired entry tries getting the new value from the DB, while the other threads also trying to hit this entry block, i.e. I use t...
I'm trying to kill a thread in python. An exception would be the preferred way to do it, as a graceful exit of the run method of the thread through a try:except: pair would allow to close resources.
I tried : http://stackoverflow.com/questions/323972/is-there-any-way-to-kill-a-thread-in-python , but is specifies that is doesn't work whi...
How do I control when a thread is permitted to access an object and when it is not.
For example, if I have situation like below, I want to make sure that when I am doing something with objFoo in my ButtonClick event, I should not be able to touch objFoo from my doSomethingWithObjFoo method.
private void button1_Click(object sender, Eve...
I've written a tool that uses inotify watches to monitor directory changes. It starts a separate thread per watched directory, each using inotify to setup the watch.
What happens to these threads/watches if the parent process is terminated with kill?
...
How do you create an intrusive slist (boost) that is threadsafe so that multiple threads can remove items or add items?
I'd want fairly fine grained locking; so I can lock only the necessary nodes and not the whole list each time.
Do I just write a wrapper class around boost slist or is it better to just implement it myself?
...
Normally it is said that multi threaded programs are non-deterministic, meaning that if it crashes it will be next to impossible to recreate the error that caused the condition. One doesn't ever really know what thread is going to run next, and when it will be preempted again.
This off course has to do with the OS Thread scheduling alg...
Hi.
Because I have a tool that needs to do a lot of work at one point, I want to show a window with some text and a progressbar while doing the work.
My problem is, that because of the huge load of the work, the window never gets drawn or updated.
I know that I usually should use an extra thread for the work, but I have to use 2 collec...
This is a two part question.
First, let's say that I have a function that is executing in a another thread:
private AutoResetEvent StopEvent = new AutoResetEvent( false);
public void WorkerThread()
{
while( !StopEvent.WaitOne( 10)) {
a();
b();
c();
}
}
Now I want to pause this thread. Thread.Suspend is out of the qu...
Hi, in trying to improve my understanding on concurrency issues, I am looking at the following scenario (Edit: I've changed the example from List to Runtime, which is closer to what I am trying):
public class Example {
private final Object lock = new Object();
private final Runtime runtime = Runtime.getRuntime();
public void...