NO Guarantee on the order of execution of threads and the
In part-4, we have seen that we can create multiple threads giving the same Runnable. Here we look at the same example and understand the order of their execution.
The above code creates a single
Runnable instance and three
Thread instances. All three
Thread instances get the same Runnable instance, and each thread is given a unique name:
t3. Finally, all three threads are started by invoking
start() on those three instances.
Multiple Threads and their Stacks
In part-3 we have seen how threads can be created and we also explored the life cycle of a thread to some extent. In this article, we will look at how threads maintain their local variables and call stacks.
Each thread in Java has a private stack associated with it. When a thread is created in Java Virtual Machine, a JVM stack local to that thread is also created.
Below is a simple java application that has one user-defined thread named
MyThread along with the
As you can see in the above…
Life Cycle of a thread with Methods in Thread Class
For managing threads in java, we have many static and instance methods in the
Thread class. We can use these methods for creating, starting, pausing, and stopping threads.
static int activeCount()
static Thread currentThread()
static void dumpStack()
static boolean interrupted()
static void sleep()
static void yield()
This is not the complete list and we will not even cover all of the above. …
Creation and Running a Thread
We have already mentioned in part-1 that a thread is an independent set of instructions that has its own private state. Every Java application has at least one thread named “main” without ourselves creating it. But what does it exactly mean when we say a Java Thread.
Well, a Java Thread is just an instance of a Java Class named
A thread in Java is just another object of class
Thread. This class offers methods to configure and operate on it. …
Program, Process, and a Thread
Multithreading is all about executing the small tasks independently inside a process. Well, there are many articles that explain what a process, thread and concurrency mean. Let me also specify the same in simple words here.
A process takes its birth from a static file called a program that contains a specific set of instructions with its associated data. A program, being a static file residing in an auxiliary memory like hard disk, has many extensions depending the programming language. For example, in Java it is .class file or an executable .jar …
The perks of merge and rebase
git merge and git rebase are excellent tools for integrating changes from one branch into another. But there is often a confusion about which one to use when.
NOTE: This can be understood better if all the commit histories in the diagrams are thoroughly followed. It will take a little more time but I am sure this will clear out all the confusions that we have about rebase and merge.
For this, we will follow an integrated approach. This post is a little comprehensive and along with git rebase and git merge, we also…
RDBMS is the wonderful technology serving remarkably well and is still a great choice for many applications. Most of us are well aware of how data are organized in relational databases (as tables and columns) and that they overcome data anomalies and avoid data redundancies. But RDBMS worked well for mid range applications and failed to meet the needs of increasing data, faster querying capabilities and flexibility in data modelling. Here are the 5 reasons why it is tough for RDBMS to handle high work loads and why organizations are moving from RDBMS to NoSQL.
Poor Performance of Join Queries…
Software Architect, Full Stack Developer, Free Lancer, Technical Content Writer