Java concurrency example-Synchronize resources using Semaphore
Semaphore is used to synchronize threads. Semaphores are often used to restrict the number of threads than can access some […]
Semaphore is used to synchronize threads. Semaphores are often used to restrict the number of threads than can access some […]
Given shared resources in java. Synchronize shares resources using Lock interface. We will use ReentrantLock to protect share resources. A
Given multi-threading application in java. Create Producer & Consumer threads. Producer thread will produces the data. Consumer thread will consumes
Given a decimal number in java (base 10) Find out number of consecutive 1’s in a binary number. 1. Examples
Given a class in java containing public,private & protected fields. Get/list/print all fields of class using class Class. We will use
Given a class in java containing public,private & protected methods. We will declare a Person class containing: Public methods. Private
Given a class in java containing public,private & protected contructors. Get/list/print all constructors (prive,protected & public) of a class using
Given a class containing public methods in java. Get/Print/list public methods/functions of class in java (example) using class Class.
Given an instance of class in java. We would like to find out the class name of an object. We
Given the parent child class hierarchy in java. We would like to compare the instance of classes at run-time. We
Given an application in java. We would like to create the instance of classes by specifying class name. Instances of
We would like to list all available time zones supported by JDK. TimeZone represents a time zone offset, and also
We would like to get/set the default timezone in java. TimeZone represents a time zone offset, and also figures out
Given a local file present on our file system. We would like to convert path of a file to URL
Given a key value pairs of properties in java.Create or write or dump properties to property file using Properties class (example)
Given an array of user defined objects/POJO in java. We would like to sort user defined objects on certain properties/data
Given a source bean or object in java. We would like to copy properties from source bean into destination bean
Given Locale for given language & country code in java. We would like to display currency code & symbol for
Given a java application supporting different languages like French,German, Korean, Japanese, English etc. We will localize strings for each language
CopyOnWriteArrayList is thread-safe variant of ArrayList. New copy of underlying array is created when any add, set (or modification) operations
Scanner class is a text parser, which is used to parse primitives & strings using regular expression. Scanner split the
Scanner is text parser which used to parse primitives & strings using regular expression. Scanner split the input into token
Inter thread communication is very common phenomenon. There are many ways to achieve inter thread communication. In current post, we
Given a file in java, check read, write & execute permissions of a file. We would like to check whether
Create new file & directory/folder using File class in java (with example). We will create new directory & file using mkdir & createNewFile respectively
List all system drives in java. We will find out the free (available) , used and total space of each
Given a zipped or compressed file in java. Write a program to unzip or decompress the contents of zip file
Given an string representing unique identifier. We would like to convert string to corresponding universal unique identifier (UUID) or Globally
Universal unique identifier (UUID) or Globally unique identifier (GUID) is unique identifier (or Id). GUID represents the unique id(s). Typically
Generate guid or uuid using RandomBasedGenerator class of Java UUID Generator (JUG) library. In current post, we will generate random uuid