Core Java Archive

Thread life cycle in java

Multi threaded application: Define and execute a Custom thread along with Default thread. When multiple threads are executing, any thread can completes execution first. Application ends only when all the threads moved to dead state. …

sleep() in java Thread class

Thread class sleep method document: Program Code: In single threaded, execution starts @ default thread and ends @ the same thread. In multi threaded, any thread can completes the execution while all the threads executing …

Can we call run() method directly?

Can we call run() method directly? Yes allowed but the logic executes from the same thread only. Run() contains the logic that should execute parallel from independent memory. Start() method is pre-defined in Thread class. …

Multiple Custom Threads in Java

How can we execute different logics from different threads? We can create multiple thread objects for a single thread class. We can define only run() method in thread class. When we start multiple threads of …

join() method – Java Thread class

join(): join() is pre-defined method in Thread class. It is non static method hence we call on Thread object. Stop current thread execution until joined thread execution completed.

Java Single Threaded – Execution time

Execution time of Single Threaded application: If the application contains only one thread, the execution becomes sequential. To understand the execution time of application, we use pre-defined method of System class. When only one thread …

Java Multi Threaded – Execution time

Execution time of Multi threaded application: When we execute different logics from different threads, time consumption will decrease. Multi threaded application increase the stress on processor by utilizing efficiently.

Daemon Threads in Java

Daemon threads: Thread behavior is either Daemon or Non-Daemon. Daemon threads execute background logic of application. Daemon threads also called service-threads. Daemon threads are invisible threads. Every thread is by default Non daemon. Non daemon …

Garbage Collection in Java

Garbage Collection: We create objects in memory (Heap area). Every object has a reference variable. Garbage collection is a mechanism of deleting objects which are no longer use in the application. Object is eligible for …

Garbage Collection Program in Java

Overriding finalize method: In the above application, we have created unreferenced objects. GC thread is not invoking finalize() method to delete those objects. GC thread invokes by JVM only when the memory is running low. …

Courses Enquiry Form