This example demonstrates a multi-threaded program that must share a resource between threads. Each thread will be required to obtain an exclusive lock on the shared resource to avoid a potentially disastrous conflict. We will create two threads, one called MissileFactory and one called MissileLauncher. The… view article
The following class demonstrates the use of Java's Format, Number, Date and Locale classes (util.*, text.*). It also shows how to serialize and de-serialize and object by implementing the Serializable interface (io.*). Item.java //Demonstrates: //Serialization, //Number/Currency Formatting,… view article
The following class demonstrates basic use of Java's Pattern and Matcher class by adding the rel attribute 'nofollow' to the anchor tags of several links. *Note, this is for educational purposes only. Pattern, Matcher and Regex are NOT ideal for manipulating HTML in Java. NoFollow.java //Adds… view article
This example shows how to connect to, and query, a MySQL database in Java using JDBC. The example will attempt to implement the singleton design pattern. The singleton design pattern restricts the instantiation of a class to one object. First get a copy of the MySQL JDBC driver at: http://www.mysql.com/downloads/connector/j/ Extract… view article
function addCol(table){ var table = document.getElementById(table); var th = document.createElement('th'); th.innerHTML = ""; table.rows[0].appendChild(th); for(i=1; i view article
A UNION is used to combine the result sets of multiple queries into one result set. The queries that are being combined may come from any table, but must have two similarities in order to be combined. The queries must return the same number of fields. If the number of fields does not match,… view article