Category: Concurrent Collections and Maps

Concurrent Collections and Maps 2 – Concurrency: Part II

Some collections allow the null value, and others do not. All concurrent collections, blocking queues, and concurrent maps do not allow the null value as elements, whereas the copy-on-write collections do. All collections that embody the concept of a set do not allow duplicates—for example, a CopyOnWriteArraySet. All maps (e.g., a ConcurrentHashMap) do not allow

Concurrent Collections and Maps – Concurrency: Part II

23.7 Concurrent Collections and Maps Most of the collections in the java.util package are not thread-safe—executing concurrent operations on them is courting disaster. Exceptions to this are the legacy Vector and Hashtable classes, but these use a single lock, allowing only one thread at a time to execute an operation on the collection while other

Concurrent Maps – Concurrency: Part II

Concurrent Maps Figure 23.5 shows the inheritance hierarchy of concurrent maps in the java.util .concurrent package. Note the interfaces ConcurrentMap<K,V> and ConcurrentNavigableMap<K,V> that extend the thread-unsafe map interfaces in the java.util package. Their implementations, ConcurrentHashMap<K,V> and ConcurrentSkipListMap<K,V>, provide efficient unsorted and sorted concurrent maps, respectively. The concrete map implementations are summarized in Table 23.9, together

The ConcurrentNavigableMap Interface – Concurrency: Part II

The ConcurrentNavigableMap<K,V> Interface A concurrent, sorted map is defined by the ConcurrentNavigableMap<K,V> interface that extends both the ConcurrentMap<K,V> and the NavigableMap<K,V> interfaces. It overrides the methods shown below from its superinterfaces. Details on these overridden methods can be found in the ConcurrentMap<K,V> interface (p. 1491) and in the NavigableMap<K,V> interface (§15.10, p. 845). The ConcurrentSkipListMap<K,V>

Blocking Queues – Concurrency: Part II

Blocking Queues Queues (and deques) are the indisputable choice when choosing a collection to manage shared data in producer-consumer problems. The interfaces for thread-unsafe queues (Queue, Deque) in the java.util package have been enhanced in the java.util.concurrent package to provide a wide variety of blocking queues that are thread-safe (Figure 23.6). These thread-safe queues are

The CopyOnWriteArraySet Class – Concurrency: Part II

The CopyOnWriteArraySet<E> Class The CopyOnWriteArraySet class implements the java.util.Set interface (§15.4, p. 804). It does not implement any additional methods. Internally it uses a CopyOnWriteArrayList, and therefore shares the same basic properties with the list, except that, being a set, it does not allow duplicates and its elements have no ordering. Example 23.21 illustrates the

Introduction to Relational Databases – Database Connectivity

24.1 Introduction to Relational Databases Relational databases are based on the relational model that provides a standardized way to represent and query data. The data is stored in tables and queried using a query language. Relational Tables Relational databases store information in tables. Each table is designed to represent a business entity that applications need

Basic SQL Statements 2 – Database Connectivity

The UPDATE Statement The UPDATE statement can be used to update specific rows in a table. In other words, this statement modifies zero or more rows in the table: Click here to view code image UPDATEtable_name SETcolumn_name_value_pairs WHERErow_filter; where column_name_value_pairs in the SET clause is a comma-delimited list of pairs of column names and values: Click here

Introduction to JDBC – Database Connectivity

24.2 Introduction to JDBC The Java Database Connectivity (JDBC) protocol provides database interaction capabilities for Java programs. The JDBC specification is not database provider specific, allowing Java programs to interact with any database. The JDBC API is defined in the java.sql package. It comprises a number of interfaces that Java programs use to represent database