multithreading

.NET: Clarification Request -Processing Threads

I am a beginner.Based on the Albahari's Producer/Consumer Solution , I have developed a code.Coding is working fine.But I have some doubts on my implementation. class FloodDisaterManagement :IDisposable { Queue<string>MedicinePack = new Queue<string>(); Thread[] volunteers; readonly object locker = new obj...

Thread Locking in Ruby (use of soap4r and QT)

[EDIT NOTE: Noticed I had put the mutex creation in the constructor. Moved it and noticed no change.] [EDIT NOTE 2: I changed the call to app.exec in a trial run to while TRUE do app.processEvents() puts '." end I noticed that once the Soap4r service started running no process events ever got called again] [EDIT NOTE 3: Cr...

C semaphores and a "barrier" between threads

I'm trying to solve a problem our Operating Systems professor showed us from a previous exam to prepare for the next one. The problem is to have two threads that execute concurrently and may complete in a different amount of time. After a particular thread is completed, it needs to block until the other thread is completed, then they ma...

Everytime u connect to an ASP.net application is a new Thread created?

Situation: My ASP.net application connects to another system for information via a TCP Connection I am trying to simulate 100 people sitting & logging to my ASP.net application at the same time and connecting to the TCP Connection Will creating a windows Application with 100 threads trying to connect to the TCP Connection provide the c...

How to make this loop's body run in parallel in C#

I've got a loop like this ICollection<Data> GetData() { ICollection<Data> result = new List<Data>() foreach (var item in aCollection) item.AddData(result); return result; } and I now need this to be executed in parallel instead iteratively. My first attempt was to do soemthing like this ICollection<Data> GetData() { IColl...

Multithreaded Syncronised List<T>

I have a requirement whereby I needed to store a simple cache of a list of items. I was using List< T > for this purpose, but we have now changed the design to accomodate multiple threads. The architecture of the system is driven by events, therefore it's quite likely that a read and write operation could collide. Since the vast majorit...

What is the correct way of manipulating Swing components at program startup?

I'm creating an application in Swing using NetBeans. I would like to be able to manipulate some components during its startup (just once), after the window's made visible, for example update a progress bar. To this end, I have the app's main class, called MainWindow: public class MainWindow extends JFrame { public MainWindow() { in...

thread usage pattern (.net wpf)

I'm having trouble understanding how to use threads. In a delegate that is called as needed to allow the user to select from a collection of projects, the first instantiation is costly due to data retrieval. The method looks like so: private void _doStandAloneProjectPickSession(ProjectDataMode dataMode) { var picker = new ProjectPick...

Multiplication...........

I've coded a .... I believe my approach is right, but I'm not 100% sure. In respect to the threads, I don't understand why I can't just run a (new MatrixThread(...)).start() instead of using an ExecutorService. Additionally, when I benchmark the ...approach versus the classical approach, the classical is much faster... What am I doing ...

Bandwidth throttling for file download

I've following code to limit file download speed for an application; context.Response.Buffer = false; context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + arquivo.Nome); context.Response.AppendHeader("Content-Type", "application/octet-stream"); context....

(MVVM) Model View View Model And Threading

Hello, I'm playing around with the (MVVM) Model View View Model design pattern but I ran into a problem with the pattern. In my scenario I'm using a DataTable as the View Model. This View Model is set as the DataSource of a DataGridView. Normally, when the Presenter adds a new row to the View Model, a new row is added to the DataGridVie...

How to instantly termainate an un-supervised script on demand?

I have a GUI which resembles an interpreter. It allows the user to write a script in Jython (implementation of Python in Java) and run it whenever he wants. Apart from that, I also wish to allow the user to instantly terminate the run whenever he wants. Thing is, I don't really know how to do it. The script is being run on a different T...

Mutlithread-safe JDBC Save or Update

We have an interesting problem: We have a JMS queue of job statuses, and two identical processes pulling from the queue to persist the statuses via JDBC. When a job status is pulled from the queue, the database is checked to see if there is already a row for the job. If so, the existing row is updated with new status. If not, a row is c...

C# Monitor.Wait and VB6 message pumping and events.

I have a com callable wrapper written in C#. The wrapper uses a Socket internally to SendAsync and ReceiveAsync. In order to make this appear synchronous to the VB6 code that calls this wrapper, I use Monitor.Wait. I can't figure out if Monitor.Wait pumps messages while it blocks. According to cbrumme's blog over on MSDN - I mentio...

Qt equivalent to Win32 Fibers.

I am responsible for a Windows application that loads up plugin "script" dll's written in c++. The application exposes an API based on Win32 fibers to allow the c++ 'scripts' in the plugin dlls to use 'yield' and 'resume' type calls - essentially co-routines - to sequence the dependencies in the scripts without resorting to an asynchron...

When does the vaIue of the InvokeRequired property change?

When i want to use delegate class to make call while windows form working, i always have to use InvokeRequired. It is ok. But who changed the InvokeReuqired property while it is working. Please check this image: ...

Timer interrupt problem in vb.net

I have 2 timers in MVB 2008 Express, one to control the fading in of a window and another to call a beep function every few seconds or so. The problem is that while the window is fading in, it pauses while the timer beeps. Any ideas? Threads maybe? ...

C# lower thread priority in thread pool

Hello, I have several low-imprtance tasks to be performed when some cpu time is available. I don't want this task to perform if other more import task are running. Ie if a normal/high priority task comes I want the low-importance task to pause until the importance task is done. There is a pretty big number of low importance task to be ...

.NET movement of threads between cores

Follow up question from Multi-core usage, threads, thread-pools. Are threads moved from one core to another during their lifetime? Of course. Imagine you have three threads running on a dualcore system. Show me a fair schedule that doesn't involve regularly moving threads between cores. This is my first time on...

Synchronize on BlockedQueue.

Hello, I have a code piece that I am reviewing (using FindBug). public class MyClass{ ... private BlockedQueue q = new LinkedBlockingQueue<MyData>(1000); private static final batchSize = 1000; public boolean testMethod(){ boolean done = false; synchronized(q){ if(q.size == batchSize){ q.notify(); done...