Java Concurrency Tutorial: Synchronization and Locks

In the next 15 min you learn how to synchronize access to mutable shared variables via the synchronized keyword, locks and semaphores. The majority of concepts shown in this article also work in older versions of Java. However the code samples focus on Java 8 and make heavy use of lambda expressions and new concurrency … Continue reading Java Concurrency Tutorial: Synchronization and Locks

Java Concurrency Tutorial: Threads and Executors

This guide teaches you concurrent programming in Java 8 with easily understood code examples. It's the first part out of a series of tutorials covering the Java Concurrency API. In the next 15 min you learn how to execute code in parallel via threads, tasks and executor services. The Concurrency API was first introduced with … Continue reading Java Concurrency Tutorial: Threads and Executors

HashSet in Java

Class HashSet<E> java.lang.Object java.util.AbstractCollection<E> java.util.AbstractSet<E> java.util.HashSet<E> Type Parameters: E - the type of elements maintained by this set All Implemented Interfaces: Serializable, Cloneable, Iterable<E>, Collection<E>, Set<E> Direct Known Subclasses: JobStateReasons, LinkedHashSet public class HashSet<E> extends AbstractSet<E> implements Set<E>, Cloneable, Serializable This class implements the Set interface, backed by a hash table (actually a HashMap instance). … Continue reading HashSet in Java

HashMap in Java

Class HashMap<K,V> java.lang.Object java.util.AbstractMap<K,V> java.util.HashMap<K,V> Type Parameters: K - the type of keys maintained by this map V - the type of mapped values All Implemented Interfaces: Serializable, Cloneable, Map<K,V> Direct Known Subclasses: LinkedHashMap, PrinterStateReasons public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable, Serializable Hash table based implementation of the Map interface. This implementation provides … Continue reading HashMap in Java

Comparator Interface and sorting in Java

Comparator interface is used to order the objects of user-defined classes. A comparator object is capable of comparing two objects of two different classes. Following function compare obj1 with obj2 Syntax: public int compare(Object obj1, Object obj2): Suppose we have an array/arraylist of our own class type, containing fields like rollno, name, address, DOB etc … Continue reading Comparator Interface and sorting in Java

How to configure Processing to run on Raspberry Pi?

Processing is an open source programming language (processing.org) and environment for people who want to create images, animations, and interactions. This is how to install it on your Raspberry PI: install the java 6 sdk sudo apt-get install librxtx-java openjdk-6-jdk download and unzip the Linux (x86) version of Processing 1.5.1 to the /home/pi directory http://processing.googlecode.com/files/processing-1.5.1-linux.tgzContinue reading How to configure Processing to run on Raspberry Pi?