ThreadLocal in Java

ThreadLocal in Java ThreadLocal is a Java concurrency technique where each thread has its own variables. In other words, if multiple threads read the same code, they cannot read and write on each other thread’s local variables. This means that each thread can read and write only its own variables. …

Read more

Runtime class in Java

Runtime class in Java The Java Runtime class is part of the java.lang.Runtime package and has several built-in methods to interact with the runtime environment of the Java application. Every java application has only 1 instance of the Runtime class. The Runtime class provides various information about the application that …

Read more

Multitasking in Java

Earlier, we have seen about multithreading in Java. In this tutorial, we will discuss multitasking in Java along with key differences between Multitasking vs Multithreading. Multitasking in Java Multitasking is the ability of the CPU to perform multiple tasks simultaneously. There will be continuous context switching of CPU between the …

Read more

ThreadGroup in Java

ThreadGroup in Java A ThreadGroup in Java represents a group of threads or thread groups and belongs to the java.lang.ThreadGroup class. The main advantage of a thread group is that we can perform operations like suspend, resume, or interrupt for all threads using a single function call. Every thread in …

Read more

Daemon Thread in Java

In the previous articles, we have seen various topics related to user threads. In this article, we will understand about daemon threads in Java, their uses, methods with examples and see differences between daemon thread vs user thread. Java Daemon thread Daemon thread in Java is a system-generated thread that …

Read more

Thread Priority in Java

Thread Priority in Java In a Java multithreading environment, every thread has a priority which is an integer value between 1 and 10 where 1 is the lowest and 10 is the highest. Thread priority is an essential concept since the scheduler picks up the threads for execution based on …

Read more

Thread Pool in Java

Thread pool in Java In Java, a thread pool is a group of threads that we can reuse for various tasks in a multithreading environment. The thread pool may be of a fixed size where each thread performs a task and once it completes it again goes back to the …

Read more

Thread scheduler in Java

Java Thread Scheduler The thread scheduler in Java is an important concept in multi-threading which is part of the JVM. The scheduler decides which thread to pick up for execution and mainly depends on two factors: time-slicing and preemptive scheduling. A thread scheduler picks up those threads that are in …

Read more

Thread in Java

In the previous tutorial, we have discussed about Multithreading in Java. In this tutorial, we will discuss in detail Thread in Java, how to create a java thread and thread lifecycle. Java Threads A thread in Java is a lightweight process or the smallest unit of a process. Each thread …

Read more

ByteArrayOutputStream in Java

ByteArrayOutputStream class in Java The ByteArrayOutputStream class in Java writes data into an array of bytes so that we can write this byte array data into any Output stream class. It stores the byte array in a buffer for later use. This buffer is dynamic in nature and grows automatically …

Read more

Translate ยป