Java – Deadlock with Example

Deadlock in multithreading is a situation where two or more than two are a lock, waiting for each other. When the first thread needs to use the same lock or wait for the object lock which is acquired by a second thread and the second thread also waits for the lock acquired by a first … Read more

Java – Inter-Thread Communication

When two or more thread needs to exchange information between them in an application, Inter-thread communication is required. Hence, we can also call it Co-Operation. The methods that are used for this communication are: wait() notify() notifyAll() 1. wait() This method is written as: This causes the current thread to wait until another thread invokes … Read more

Java – Static Synchronization

This method is used to achieve static synchronization which locks a class, not an object. Why use static synchronization? Consider a shared class ‘Numbers’ for two objects (obj1 and obj2). The use of the synchronized method and synchronized block cannot interfere between the objects created(th1 and th2 or th3 and th4) for shared class because … Read more

Java – Thread Synchronization

Having multiple threads in a program may cause inconsistency and thread interference, that is the multiple threads when trying to access the same resource. One thread may try to write and another may try to read the shared resource or same file. So to achieve the use of only one resource or file at a … Read more

Java – Multithreading with Example

What is Multithreading? The execution of multiple threads or tasks is called multithreading. The main purpose of multithreading is to achieve the simultaneous execution of more than two tasks so to maximize the use of CPU time. Thread is a light-weight sub-process or we can say that it is the smallest part of the process. … Read more

Java – Arrays

An array is a group or the collection of data having the same data-type. Arrays are objects in Java and with the fixed size(disadvantage). Elements are arranged inside the array with index numbers starting from zero as the first elements.Random access of any element present in the array and code optimization feature makes it more … Read more

Java – Multi-Dimensional Array

Declaring an array of arrays is known as Multidimensional Array or Jagged Arrays. In simple words, it is an array of arrays. It is created by appending a square brackets “[]” for each dimension. Here data are stored in a tabular form that is in row-major order as shown in an example below. Syntax: Declaration: … Read more

Java – One-Dimensional Array with Example

A one-dimensional array in Java is an array with a bunch of values that are declared with a single index. Here data are stored in a single column as shown below in an example. Array declaration: Example: An array declaration has two components:The type that is the data-type of an element and the name that … Read more

Java – Jump Statement

In Java, Jump statements are used to interrupt loop or switch-case instantly to transfer the program control from one point to elsewhere in the program.Java supports three jump statements: continue.  break  return. break:  This statement is used within the loop or switch cases to terminate that statement or the current loop is immediately stopped and … Read more

Java – continue statement with Example

It is one of the jump statement in java. It is used in loops to jump immediately to the next iteration of the loop. continue is used with while loop or do/while loop and with for loop. When continue is used inside for loop then the control immediately jumps to the increment or decrement part … Read more