It is currently Fri May 18, 2012 5:58 pm


Post a new topicPost a reply Page 1 of 1   [ 1 post ]
Author Message
 Post subject: Synchronization and Arraylists
PostPosted: Sat Aug 28, 2010 4:59 pm 
Site Admin

Joined: Sat Aug 02, 2008 8:00 am
Posts: 147
Synchronized is defined as an Objective-C, D and Java programming language. It indicates a block of code subject to a mutual exclusion algorithm. Two of the most common synchronization principles include synchronized methods and synchronized statements. The synchronized methods are considered simpler compared to the synchronized statements. The synchronized methods are highly effective as a synchronized method can only be accessed by one thread at any point of time. In short, this method prevents concurrent access. On the other hand, the synchronized statement is capable of ascertaining only one thread running a block of codes. Here, each object has an internal lock for synchronization purpose. Synchronized can also be a modifier.
The arraylist, alternatively, is defined as a random access, variable-size list data structure. According to the Wikipedia, it allows elements to be added and removed in java and can support mainstream programming languages. An arraylist is rather uncomplicated and it is suitable to be used in legacy programmes. It is a data structure in Microsoft .NET Framework which includes Methods to assist the programmer, particularly in admitting and storing data within the arraylist. The arraylist hold its contents using the Array. Also, the arraylist is a professional data structure in retrieving elements from a specific position in the container. Adding and removing elements from the end of the container is also a usage of the arraylist.
A programmer might sometimes be confused: the vector or the arraylist offers better service? The answer is: it depends on circumstances. The vector might do better job today and arraylist will do better job tomorrow. All in all, factors such as API, synchronization, data growth and usage patterns. The vector is described as analog to the arraylist. However, the vector is definitely speedier than the arraylist.
When we say arraylist that is synchronized, it implies that it is thread-safe. It will keep adding, modifying, and deleting thread-safe. To get a synchronized arraylist, it is contended that when iterating over the synchronized list one needs to synchronize on it in order to avoid unintended circumstances. This might due to the reason that the existence of a single iterator yet multiple threads is capable of interating it over at the same time. Moreover, the arraylist does not guarantee the a managed code to be thread safe, even it is equipped with a Syncronzied() version of the arraylist. Adversely, the arraylist only guarantees that the internal data structures are thread safe, which is rather logical.

_________________

Muhammad Safwat Fuad
The Java Code Admin
Java Technical Lead.
Mobile: +2010-2942-538
Email:mtv134@yahoo.com


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 1 post ]


Who is online

Registered users: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
twilightBB Style by Daniel St. Jules of Gamexe.net

[
SEO MOD © 2007 StarTrekGuide ]