thread-safety

C# HTTPWebRequest Multi-threading

Hi all, I am new to threading. I am trying to send HTTP Web Request using multi threading, I am not able to acheive what I need. My requirement is to send request to thousands of same or different websites and parse the response i get it from httpwebrequest. In the below code, i am sending 2 simulteaneous threads, I am looking for ten...

Approach to a thread safe program

All, What should be the approach to writing a thread safe program. Given a problem statement, my perspective is: 1 > Start of with writing the code for a single threaded environment. 2 > Underline the fields which would need atomicity and replace with possible concurrent classes 3 > Underline the critical section and enclose them in...

Dispatcher.BeginInvoke lambda capture thread-safe?

In Windows Phone 7 / Silverlight, is the following code safe or is it a race condition? //Snippet 1 foreach(var item in list) { Deployment.Current.Dispatcher.BeginInvoke( () => { foo(item); }); } Surely (?) this alternative is racy? //Snippet 2 Deployment.Current.Dispatcher.BeginInvoke( () => { foreach(var item in li...

Is java.util.Vector serialization thread-safe?

I know the Vector class is thread-safe for adding and removing elements [reference]. If I serialize a Vector using an ObjectOutputStream am I guaranteed a consistent (and non-corrupt) state when I deserialize it even if other threads are adding and removing objects during the seralization? ...

Fast data recording/logging on a separate thread in C#

Hello, We're developing an application which reads data from a number of external hardware devices continuously. The data rate is between 0.5MB - 10MB / sec, depending on the external hardware configuration. The reading of the external devices is currently being done on a BackgroundWorker. Trying to write the acquired data to disk with...

Model, View, Controller - I understand the class diagram, but I don't understanding all the threading issues. Advice?

I recently read the Head First Design Patterns book and I especially liked how the chapter on MVC seemed to bring everything together from the previous chapters. However, I am now on the verge of implementing a MVC pattern (using wxWidgets in C++) and I am beginning to realize that I don't understand threading issues as much as I should...

Python Threading Concept Question

I'm currently in the process of writing a client server app as an exercise and I've gotten pretty much everything to work so far, but there is a mental hurdle that I haven't been able to successfully google myself over. In the server application am I correct in my thinking that threading the packet handler and database handler to work ...

CopyOnWriteArray or Vector

All, The edge Vector class has over ArrayList is that it is synchronized and hence ensures thread safety. However, between CopyOnWriteArray and Vector, what should be the preferred considering thread safety and performance in consideration. ...

Is Java.sql's getRow() thread safe?

Lets say I have a large number of threads inserting into a mysql database using Java.sql. After i perform an insert i would like to know the primary key of the record i just inserted. I could use getRow() on the ResultSet returned by the insert query. However, is this thread safe? Or should I fire off another select statement to f...

Is this code thread and sync safe?

Hi, I need an authentication token to be thread and sync safe. The token will expire every hour and so a new one will need to be created and assigned to my static variable (TOKEN) Will this do the trick? Thanks, public static volatile string TOKEN = string.Empty; public static DateTime TOKEN_TIME = DateTime.Now; private s...

Is C#'s using statement abort-safe?

I've just finished reading "C# 4.0 in a Nutshell" (O'Reilly) and I think it's a great book for a programmer willing to switch to C#, but it left me wondering. My problem is the definition of using statement. According to the book (p. 138), using (StreamReader reader = File.OpenText("file.txt")) { ... } is precisely equivalent to: ...

How to prevent a request scoped bean method being called multiple times in a JSF application?

Ok, with all the answers to this question I'm still not able to handle my problem. I have the following constellation: In a JSF (1.1) webapp I have a request scoped bean beanof class Bean. When the user quickly clicks a commandButton multiple times to redirect him to the insult.xhtml page the doSomethingThatTakesALittleLongerAndShouldOn...

.NET DataGridview scroll setting in another thread

i have a gridview whose scroll bars r selected "Both"......now this grid view in updated by a new datasouce in other thread.....but problem in when it is updated its vertical scroll bar diss appears and even not settled when i set it in other thread ...Here is the code Public Sub LoadList() dgvRFQs.DataSource = MyDal.GetAllQuotation...

Embedding Python thread safe

Hi everyone, I'm trying to use Python in a module for an analysis software of vehicle bus systems. For this I have to embed Python in a thread safe manner, since there can be multiple instances of the module witch work independently. I could use a mutex to guard all access to Python and create an unique (python) module for every thread...

JAVA: Concurrency control for access to list in java

I have a multi-threaded application that has a centrlaised list that is updated (written to) only by the main thread. I then have several other threads that need to periodically retrieve the list in its current state. Is there a method that can allow me to do this? ...

Is jBCrypt 0.3 threadsafe?

Question says it all really. Code can be found at the following link -> http://www.mindrot.org/projects/jBCrypt/ ...

Is match(Uri) of class UriMatcher reentrant?

The examples that I have seen of how to make a ContentProvider have all used the UriMatcher#match(Uri) method within the insert, query, update, and delete methods to easily handle all of the URI patterns that the content provider responds to (e.g.: http://developer.android.com/resources/samples/NotePad/src/com/example/android/notepad/Not...

how can I avoid performance bottleneck when using jni in a java web application/service

Greetings, I could not provide all the details in the question, so here are the key details. I have a native dll (and a corresponding .so) wrapping a static library, which is created by Eiffel programming language. I've written a C++ wrapper around the static lib, and I've successfully exposed this to Java. However, if I use this dll ...

Thread safety when updating data bound objects from non UI thread (WPF/Silverlight)

This may be seen as a duplicate of http://stackoverflow.com/questions/3423248/thread-safety-lists-binding-and-wpf, but I post it anyway since I'm not fully happy with the accepted response, and I might be able to express what I suspect is the same question more exactly. Any operations related to UI in WPF/Silverlight must be performed o...

Could this code kill my server ?

Hello Im having an ongoing issue with my site, it basically times out and dies. I have gotten to the point now where I have had to set the application pool to auto recycle every 5 minutes, but even that has failed as I’ve just got back from work and my email inbox is full of 4000 emails all with the same error. System.Data.SqlClient.Sq...