multithreading

Can't safely lock a value of a ConcurrentDictionary

Hi, I asked a question about this yesterday and got lots of helpful feedback (thanks!) but I don't think I gave enough information in the question - hence, another. I have two threads which concurrently read two files. They put the information from these files into two ConcurrentQueues. Another two threads then come along, dequeue item...

Update WPF ProgressBar that is bound to a dependency object running a long process.

I want to bind the value property of a WPF ProgressBar to a dependency property that is updated during a long running process. If the long running process is called from the main thread then this blocks the UI (and hence the ProgressBar) from updating until the process completes - preventing the desired progress through the process being...

Safe publication when values are read in synchronized methods.

My question concerns safe publication of field values in Java (as discuessed here http://stackoverflow.com/questions/801993/java-multi-threading-safe-publication). As I understand it, a field can be safely read (meaning access from multiple threads will see the correct value) if: read and write are synchronized on the same monitor fie...

How to execute IronPython script in separate thread and then suspend it?

Lets assume I have such code for testing. public class SimpleScheduler { public Script Script { get; set; } private Thread _worker; public void Schedule() { this._worker = new Thread(this.Script.Execute); this._worker.Start(); } public void Sleep() { //? } } SimpleScheduler ju...

GetThreadTimes on Solaris 10 x86 C++

I want a similar function similar to the VC++ GetThreadTimes function to work on solaris. I need a monitoring tool to monitor thread and monitor execution time from another thread. Is there a direct way of doing this? I have found that getrusage() can do this only to get the value of times() for the calling thread. But I what I want to...

Pass Parameter to thread problem.

hi. In a datagridview I have an IP address field. when I click on check status button I make thread for each row in datagridview and then call a remote object on the host on that IP and get some information and set another datagridview field as thath info. but there is a problem. the info is wrongly set on datagridview. why? privat...

Interlocked class

Hello everyone. Up to this point I used lock(object) construction for acces to shared variables. After reading msdn article about Interlocked The Increment and Decrement methods increment or decrement a variable and store the resulting value in a single operation. On most computers, incrementing a variable is not an atomic operation,...

Why can't a Java Thread object be restarted?

I know that it is not possible to restart a used Java Thread object, but I don't find an explanation why this is not allowed; even if it is guaranteed that the thread has finished (see example code below). I don't see why start() (or at least a restart()) method should not be able to somehow reset the internal states - whatever they are...

Where's the segmentation fault being generated in this threaded code?

In this homework, two matrices should be added using a different thread for each quadrant. This is my attempt so far, it generates a seg fault that I haven't been able to identify. #include <math.h> #include <stdio.h> #include <stdlib.h> #define N 4 //matrix dimension int c[4][4]; int a[4][4]={1 ,3, 4, 5, 3, 4, 5, 6,7, 8, 9, 0, 2, 1...

How to force execution in new thread

I have such code in my app: var t = new Thread(new ThreadStart(new Action(SomeClass.SomeMethod))); t.Start(); ... t.Join(); but as I understand, compiler does some optimization and run SomeMethod in the same thread as main code. I check this by setting different Names of the thread in t and Thread.CurrentThread. How I can create and ...

Thread switching and deadlock prevention problem

if there are two threads as producer/consumer is it good idea to have following line to prevent deadlocks. I'm aware of live locks but suppose they do a lot of work before calling this Wait() method: // member variable object _syncLock = new object(); void Wait() { lock (_syncLock) { Monitor.Pulse(_syncLock); ...

How can I send messages (or signals) from a parent process to a child process and viceversa in Perl?

Hi, Im writing a program that manage muti-processes. This is what I have done and its working great! but now, I want to send messages from the child processes to the parent process and viceversa (from the parent to the childs), do you know the best way? Do you know if what I have done is the proper way for what I want (send messages, or ...

Does Task.Wait(int) stop the task if the timeout elapses without the task finishing?

I have a task and I expect it to take under a second to run but if it takes longer than a few seconds I want to cancel the task. For example: Task t = new Task(() => { while (true) { Thread.Sleep(500); } }); t.Start(); t.Wait(3000); Notice that after 3000 milliseco...

Does it make sense to set up mediaPlayer to run in a separate thread in Android?

I've recently begun experimenting with a mediaPlayer instance in my Android app. I implemented a couple different beeps for feedback to the user. Now, when I implemented an audioTrack (for a completely different purpose), I discovered that it pretty much sets itself up as a separate thread automatically (as far as I can tell). It cert...

How do you keep an indeterminate progress bar from freezing?

What good is an indeterminate progress bar that is frozen because of course its on the same thread? Is there a way to keep it running? Possibly multi-threading? ...

Is there something analogous to Qt::QueuedConnection in .NET?

In Qt, there is a nice idiom to have each object associated with a thread, so that all its event handlers will only run in that thread (unless called directly, of course). Is there anything even remotely like that in C#/.NET? If not, how would you start writing your own? Example: // threaded.h #include <QThread> #include <QDebug> #in...

Does this behavior of setInterval imply multithreading behavior in Javascript?

Hello people. In using javascript i noticed this thing. You can use var i=0; var startingTime=new Date().getTime(); setInterval("foo()",1); function foo() { i+=1; if ($("#foodiv").text()==i) { //we detected a doubled value (parallel execution) $("#repdiv").append("[repetition on "+i+"]"); } $("#foodiv")....

Multiple Invocations of Spring Scheduled Task

Hey everyone, So I am having a bit of a problem with some scheduled tasks I have declared using Spring's @Scheduled annotation. First off here is my app-config: <beans <!--Namespaces-->> <!-- Search for annotated beans --> <context:component-scan base-package="com.my.package.task"/> <task:annotation-driven executor="myExe...

How many bytes does my function use? (C#)

I would like to calculate how many bytes my function fills so that I can inject it into another process using CreateRemoteThread(). Once I know the number of bytes, I can write them into the remote process using the function's pointer. I have found an article online (see http://www.codeproject.com/KB/threads/winspy.aspx#section_3, chapte...

Static variable across multiple requests

In order to improve speed of chat application, I am remembering last message id in static variable (actually, Dictionary). Howeever, it seems that every thread has own copy, because users do not get updated on production (single server environment). private static Dictionary<long, MemoryChatRoom> _chatRooms = new Dictionary<long, Memor...