I've learned that every class byte code is been loaded to the memory once for each class loader, thus when a thread is executing the byte code of some method, and another thread comes along?
1 thread -> 1 instance - of class Foo == no problem.
X threads -> 1 instance - of class Foo == need to be handled this is clear.
X threads ->...
I just learned about queues in .NET and I have a few questions.
Let's say that I'm building an application that downloads the HTML of pages and then processes it. Here's how I want it to operate:
A main thread adds URLs to a queue
This queue is read by two other threads. They "dequeue" a URL and then download the corresponding HTML.
T...
I've hit against what I think is a race condition. What options do I have to debug it?
More details:
I have a Silverlight application which uses Telerik grid. The columns can be customised by the user by using a column chooser attached to the grid. In a particular case where the list of possible columns are created via the code, when I ...
I have a suspicion that there might be a race condition in a certain C++ multithreading situation involving virtual method calls in a vtable dynamic dispatching implementation (for which a vtable pointer is stored as a hidden member in the object with virtual methods). I would like to confirm whether or not this is actually an issue, an...
Dear learned folk,
I made a web app that loads images using jquery, ajax and json. I got it to work in Firefox, but alas, Safari and Chrome remain stubborn.
It has to do with a "race condition" where images don't load quickly enough, so I have a load event as well as a trigger event to wait until all images are loaded before appending t...
Please consider the following code and the explanation from this Mozilla tutorial "Using web workers":
var myWorker = new Worker('my_worker.js');
myWorker.onmessage = function(event) {
print("Called back by the worker!\n");
};
Line 1 in this example creates and
starts running the worker thread.
Line 2 sets the onmessage hand...
I am attempting to track events when links are clicked on my site in a method similar to the following.
<a href="/example" class="track">Example</a>
<script type="text/javascript">
jQuery(function($) {
// track clicks on all anchor tags that require it
$('a.track').live('click', function(e) {
// send an ...
If I want to rename A to B, but only if B doesn't exist, the naive thing would be checking if B exists (with access("B", F_OK) or something like that), and if it doesn't proceeding with rename. Unfortunately this opens a window during which some other process might decide to create B, and then it gets overwritten - and even worse there's...
I have this sub :
Private Sub error_out(ByVal line As Integer, ByVal err_col As Integer, ByVal err_msg As String)
Dim ln = t_erori.Rows.Add
ln.Item(0) = line
ln.Item(err_col) = err_msg
ln.Item(3) = err_col
End Sub
This is being called by several functions running in a parallel.for l...
In a POSIX environment, I want to remove a file from disk, but calculate its checksum before removing it, to make sure it was not changed. Is locking enough? Should I open it, unlink, calculate checksum, and then close it (so the OS can remove its inode)? Is there any way to ensure no other process has an open file descriptor on the file...
If you're wondering what the "Race Condition" is, its a flaw in a system whereas it's highly dependent on timing. See the wiki here for more info.
So, the condition i have is relating to Facebook Connect and implementing a Single-Sign-On service with an ASP.NET 4.0 Web Application (Forms Based Authentication - IIS7).
The process itself...
Hello there,
I'm creating some temporary files in the iPad simulator. To test my file creation, I create the file and then read it back. Here's some code to show this:
-(NSString *) writeToTempFile:(UIImage*) image{
NSString *path = [self createTemporaryFile];
NSLog(@"path: %@", path);
NSData *data = UIImageJPEGRepresentation(image, 1)...
I'm writing an application with a layered communications interace. This was done to abstract the communications from the user-interface part of the application and also to make it more scaleable/maintainable. For instance:
Consider each box in the figure above as a separate class. The Generic Comms Interface populates string variab...
I have been working on a new feature for a facebook game I have written. The game allows a player to travel between cities in Europe and deliver goods for profit. This feature that I'm adding adds pathfinding AI to the game: it allows a player to select a city to travel to, then the game automatically moves the player's train along track...
I've moved on from trying to use OpenGL through Penumbra to trying to draw directly on a JPanel using its Graphics context.
This would be great, except I'm running into some trouble… I compile my code, and ~1 time out of 25, the graphic (it's a rectangle for the example) draws just fine. The other ~24 times, it doesn't.
Here's my code...
I have a unique problem. There are two processes (P0 and P1) trying to access one file. P0 is writing information to the file and P1 is reading the information. There is a race condition occurring between the two in which P1 is reading before P0 is finished writing. I have considered using Locks, Semaphores, etc. However, P1 exists in a ...
I'm building an ASP.NET MVC 2 site that uses LINQ to SQL. In one of the places where my site accesses the DB, I think a race condition is possible.
DB Architecture
Here are some of the columns of the relevant DB table, named Revisions:
RevisionID - bigint, IDENTITY, PK
PostID - bigint, FK to PK of Posts table
EditNumber - int
Revis...
My workplace uses Hudson for its daily builds, with several build slaves (one Linux, one Windows, one Mac) checking out our full codebase from svn and building our app at midnight each day. This all works fairly well.
There is an occasional problem that happens though... sometimes a developer will be working late, and will check in a c...
Write a class named RaceHorse that extends Thread. Each RaceHorse has a name and run() method that displays the name 5000 times. Write a Java application that instantiates 2 RaceHorse objects. The last RaceHorse to finish is the loser.
This is the question.
I have written the code for the two classes two run the thread
Here are the code...
Hello,
My client has a ecommerce website that sells electronics, and there has been situations where a product is sold more times than they have in their inventory. This is because if two users buy a product at the same time when there is only one product left in stock, one session does not finish registering the product as sold out bef...