Hey Algos,

Technology is growing my man, what you believed correct yesterday becomes wrong today. Yeah, that is what technology.

It’s a long time no see. After a long break, I thought to write something for you, and it is about gRPC. Now, most of you do not know the term RPC but I assume that you have at least a basic knowledge of REST. Because in the later part of this blog post, I will be comparing REST and RPC. It is better that you know about REST. However, you can continue reading without knowing REST because RPC does…


A thread is simply a sequence of programmed instructions that can be executed independently in a CPU. A single process of a program can have several threads, these threads are executed parallelly at the same time within the same process.

There are two types of processes based on the number of threads.

  1. Single-threaded processes. :- Only one task is executed.
  2. Multi-threaded processes. :- Multiple tasks can be executed parallelly.

Why we need Threads.

A process of a program may have more than one task to be executed at the same time, creating a new process for each of these tasks is time-consuming and resource-intensive…


The terms Mutability and Immutability in programming are very important topics to understand the behavior of a language. It’s always better if you have a great foundation of knowledge in those core concepts of programming. In this little article, what my intention is to give an insight of the term shared mutability. But before learning about that, you indeed need an understanding of Mutability and Immutability itself.

So, let’s briefly look at those two things.

What is the main difference between Mutability & Immutability

The main difference here is that the immutable objects are unchangeable after it is created.

Let’s see some examples in Java

public class Car {…


It seems like Java is creating a turning point, for a long time java developers are kind of restricted in a way of Object-Oriented thinking which is powerful at the production level. But that restriction forces us to do everything in that manner, no matter which kind of thing we are doing. For example, you have to type the following commands just for printing the hello world to the console.

public class Main{
public static void main(String[] args){
System.out.println("Hello World");
}
}

Don’t you feel like we are doing so many things just for printing a line, that’s because of…


For many GUI programming languages, one of the most powerful projects for understanding the behavior of a particular language is the Calculator app. even though it is kind of kid’s work, it might help you to figure out some of the pretty basic and important concepts.

I am as a Java developer, who writes thousands of Java codes, and do not know much about any other languages, the better choice for me is to start up with a Calculator for learning a new technology. …


To enhance the speed of a program, we use multiple threads to access the same resource at the same time. But, this kind of shared resources can produce unexpected results due to this simultaneous access made by multiple threads. The following example demonstrates the problem.

Here, we have a sample bank system that contains 4 classes that are responsible for updating the account balance of a particular customer. The task is to update the account by 10 dollars 100 times. To accomplish the task we created a cached thread pool which creates 100 threads when executing it.

The Account class…


Suppose there is server software that creates new threads for each and every client request. When there are a million number of clients are requesting different tasks through the server, the server must create million of threads for them which is a very expensive operation and could limit throughput to cause poor performance.

The solution for this problem is solved by the Thread pools in Java. Simply, a thread pool is a collection of pre-initialized threads. These threads will be applied to a given set of tasks, no new threads will be created. It facilitates the execution of N number…


Java provides a bunch of methods to manage threads that we create. A few of the most important methods are listed down below.

Now let’s see how each of these methods is working with examples. getName() Method


A thread is the smallest sequence of instruction executions that can be scheduled by an OS scheduler to run on a CPU. A thread is living inside a process and it is considered a lightweight process.

Threads are the fundamental model of program execution in a Java program, and the Java language and its API provide a rich set of features for the creation and management of threads. All Java programs comprise at least a single thread of control-even a simple Java program consisting of only a main() method runs as a single thread in the JVM. Java threads are…

Hashan Mahesh

I am an undergraduate at the University of Kelaniya, Sri Lanka. I study Information Communication Technology including Artificial Intelligence technologies

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store