- 20 January
How to check if number is power of two
In this tutorial, we will see how to check if number is power of two. There are many approaches to check if number is power of two or not. Approach 1: It is very easy and straight forward approach. Run a while loop which checks for condition if n is even number (n%2==0). If n is […]
- 16 January
How to prepare for AWS Certified SysOps Administrator Associate certification exam
In my previous articles, I have written about solutions architect exam and list of AWS certifications. AWS is the market leader in the cloud computing platform. If you are planning to switch your career to cloud computing, then AWS is the right place to start your learning process. Microsoft Azure is the only competitor for […]
- 13 January
Android SQLite Database CRUD example
In this tutorial, we are going to learn about Android SQLite database CRUD example. Android SQLite is open source relational database which can be used for performing crud operations. You don’t have to do explicit installation for it. It is available by default in android. Let’s start with simple example: In this example, we will […]
- 09 January
Java ExecutorService example using Callable and Future
Callable interface represents a thread that can return a value. It is very much similar to Runnable interface except that it can return a value. Callable interface can be used to compute status or results that can be returned to invoking thread. For example: Let’s say you want to perform factorial and square of some […]
- 06 January
Object level locking vs Class level locking in java
Synchronization is ability to restrict access to shared resource to only one thread. When two or more threads need access to shared resource, there has to be some mechanism such that shared resource will be used by only one thread. The process by which we can achieve it is called Synchronization. Why do you need […]
- 06 January
Java Exchanger example
Exchanger class is introduced with java 1.5 with other classes such ConcurrentHashMap, CountDownLatch, Semaphores. Exchanger class is used to exchange object between two threads. Exchanger simply waits until two separate threads calls exchange method, when it happens, it exchanges data supplied by threads.Two threads can pair and swap objects between them. Exchanger class may be useful […]
- 05 January
Java newCachedThreadPool Example
1. Introduction Java’s Executors.newCachedThreadPool() factory method provides a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available. Our goal is to understand how to use this thread pool to execute asynchronous tasks efficiently. 2. What is newCachedThreadPool? The newCachedThreadPool method from the java.util.concurrent.Executors class is a […]