I have an application where 2 threads are running... Is there any certanty that when I change a global variable from one thread, the other will notice this change?
I don't have any syncronization or Mutual exclusion system in place... but should this code work all the time (imagine a global bool named dataUpdated):
Thread 1:
while(1) ...
When a class field is accessed via a getter method by multiple threads, how do you maintain thread safety? Is the synchronized keyword sufficient?
Is this safe:
public class SomeClass {
private int val;
public synchronized int getVal() {
return val;
}
private void setVal(int val) {
this.val = val;
...
I wrote a Java program to add and retrieve data from an MS Access. At present it goes sequentially through ~200K insert queries in ~3 minutes, which I think is slow. I plan to rewrite it using threads with 3-4 threads handling different parts of the hundred thousands records. I have a compound question:
Will this help speed up the prog...
I have a process in a website (Asp.net 3.5 using Linq-to-Sql for data access) that needs to work as follows:
Upload file
Record and save info regarding file to database
Import data from file into database
Redirect to different page
When run sequentially like this, everything works fine. However, since the files being imported can be ...
Hi, I´m programming a .NET Compact Framework application which shows maps on a PDA.
I´ve created an ad hoc component that paints it´s own piece of the whole map, using several of this components the big picture is composed. I did it this way to avoid the latency of painting the whole map in a single step.
What I would like to do know i...
I have two threads in an Android application, one is the view thread, and the other a worker thread. What i want to do is to sleep the worker thread until the view thread terminates the handling of the onDraw method.
How i can do this? is there a wait for a signal or something?
...
What is the proper technique to have ThreadA signal ThreadB of some event, without having ThreadB sit blocked waiting for an event to happen?
i have a background thread that will be filling a shared List<T>. i'm trying to find a way to asynchronously signal the "main" thread that there is data available to be picked up.
i considered ...
Consider a hypothetical method of an object that does stuff for you:
public class DoesStuff
{
BackgroundWorker _worker = new BackgroundWorker();
...
public void CancelDoingStuff()
{
_worker.CancelAsync();
//todo: Figure out a way to wait for it to be cancelled
}
}
How can one wait for a BackgroundWorker to...
I have built an application in C# that I would like to be optimized for multiple cores. I have some threads, should I do more?
Updated for more detail
C# 2.0
Run on Windows Vista and Windows Server 2003
Updated again
This code is running as a service
I do not want to have the complete code... my goal here is to get your experience...
I need to do some simple timezone calculation in mod_perl. DateTime isn't an option. What I need to do is easily accomplished by setting $ENV{TZ} and using localtime and POSIX::mktime, but under a threaded MPM, I'd need to make sure only one thread at a time was mucking with the environment. (I'm not concerned about other uses of loca...
I have seen this link: Implementing Mutual Exclusion in JavaScript.
On the other hand, I have read that there are no threads in javascript, but what exactly does that mean?
When events occur, where in the code can they interrupt?
And if there are no threads in JS, do I need to use mutexes in JS or not?
Specifically, I am wondering ab...
I'm looking for the simplest, most straightforward way to implement the following:
The main program instantiates worker
threads to do a task.
Only n tasks can be running at once.
When n is reached, no more workers
are started until the count of
running threads drops back below n.
...
I am investigating the design of a work queue processor where the QueueProcessor retrieves a Command Pattern object from the Queue and executes it in a new thread.
I am trying to get my head around a potential Queue lockup scenario where nested Commands may result in a deadlock.
E.G.
A FooCommand object is placed onto the queue which ...
I followed google to this MSDN forum thread.
The last answer was and I qoute : "Using threads? Don't"
Does someone knows a walk around?
As far as I can tell, I'm playing the cards well.
I'm using BeginInvoke inorder to populate the data source inside the UI thread.
More details :
I've got a background thread that make queries to a S...
I'm having trouble understanding STA and MTA. If you could explain it in your own words that would be great. Also what are Apartment threads and do they pertain only to COM? If so why?
...
I have a multi thread application built on Java and I need to set different priorities to this threads. In windows it works fine, a bigger value (priority) gets more CPU time just like it was supposed.
On Linux, I cant find a logical answer to how it is working. Looked online, but can't seem to find a definitive answer on how its worki...
If I create an event using CreateEvent in Windows, how can I check if that event is signaled or not using the debugger in Visual Studio? CreateEvent returns back a Handle, which doesn't give me access to much information. Before I call WaitForSingleObject(...), I want to check to see if the event is signaled before I step into the func...
My form receives asynchronous callbacks from another object on random worker threads. I have been passing the data to the main thread (where it can be used to update onscreen controls) using delegates as shown below. Performance is dreadful -- once I reach 500 updates per second, the program completely locks up. My GUI processing itse...
I recently inherited a small Java program that takes information from a large database, does some processing and produces a detailed image regarding the information. The original author wrote the code using a single thread, then later modified it to allow it to use multiple threads.
In the code he defines a constant;
// number of thr...
In a VB.Net Windows Service I'm currently pooling units of work with:
ThreadPool.QueueUserWorkItem(operation, nextQueueID)
In each unit of work (or thread I'll use for ease of understanding), it will make a couple MSSQL operations like so:
Using sqlcmd As New SqlCommand("", New SqlConnection(ConnString))
With sqlcmd
...