Flat Preloader Icon

Naming a thread and fetching name

Thread can be referred to as a lightweight process. Thread uses fewer resources to create and exist in the process; thread shares process resources. The main thread of Java is the thread that is started when the program starts. now let us discuss the eccentric concept of with what ways we can name a thread. … Read more

Runnable interface in Java

java.lang.Runnable is an interface that is to be implemented by a class whose instances are intended to be executed by a thread. There are two ways to start a new Thread – Subclass Thread and implement Runnable. There is no need of subclassing a Thread when a task can be done by overriding only run() … Read more

Java.lang.Thread Class in Java

TThread a line of execution within a program. Each program can have multiple associated threads. Each thread has a priority which is used by the thread scheduler to determine which thread must run first. Java provides a thread class that has various method calls in order to manage the behavior of threads by providing constructors … Read more

Main thread in Java

Java provides built-in support for multithreaded programming. A multi-threaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution.When a Java program starts up, one thread begins running immediately. This is usually called the main thread … Read more

Java Thread Priority in Multithreading

As we already know java being completely object-oriented works within a multithreading environment in which thread scheduler assigns the processor to a thread based on the priority of thread. Whenever we create a thread in Java, it always has some priority assigned to it. Priority can either be given by JVM while creating the thread … Read more

Lifecycle and States of a Thread in Java

A thread in Java at any point of time exists in any one of the following states. A thread lies only in one of the shown states at any instant: New State Runnable State Blocked State Waiting State Timed Waiting State Terminated State The diagram shown below represents various states of a thread at any … Read more

Multithreading in Java

Multithreading is a Java feature that allows concurrent execution of two or more parts of a program for maximum utilization of CPU. Each part of such program is called a thread. So, threads are light-weight processes within a process. Threads can be created by using two mechanisms : Extending the Thread class Implementing the Runnable … Read more

java.lang.Character class methods | Set 1

lang.Character class wraps the value of a primitive data type – char to an object of datatype char and this object contains a single field having the data type – char. This class provides no. of methods regarding character manipulations like converting them from lowercase to uppercase. Character class is based on UnicodeStandards to provide … Read more

Quantifiers in Java

Prerequisite: Regular Expressions in Java Quantifiers in Java allow users to specify the number of occurrences to match against. Below are some commonly used quantifiers in Java. X* Zero or more occurrences of X X? Zero or One occurrences of X X+ One or More occurrences of X X{n} Exactly n occurrences of X X{n, … Read more

Pattern pattern() method in Java

The pattern() method of the Pattern class in Java is used to get the regular expression which is compiled to create this pattern. We use a regular expression to create the pattern and this method used to get the same source expression. Syntax: public String pattern() Parameters: This method does not accepts anything as parameter. … Read more