Immutable Objects in Java. The Main Aim and Usage.


What are immutable objects in Java Immutable objects are multifunctional objects that can be used in different parts of the program. For example,  immutable objects can be in a multithreaded environment for working with data. They can also be complex constants that help you avoid unnecessary memory usage and garbage collector overloading. Separately we should mention immutability when working with collections. The main parameters of immutable classes Saying that a class is immutable, it must correspond to the following criteria: Do not provide methods that modify the object’s state. These…

Read More

Multithreading in Java. Overview of Runnable, Thread, Object.


Two basic entities represent multithreading in Java. There are processes and threads. Java uses threads more often in multithreading programming. However, there are multi-process applications in Java as well. Processes in Java A process is a self-contained program with an execution environment. Each process has its own memory space. Often the term process refers to an entire application. Communication between processes happens by IPC resources: pipelines or sockets. To create a multi-process application, use the ProcessBuilder class. Threads in Java Thread – often referred to as a lightweight process. Like…

Read More