Skip to main content

Posts

Showing posts from August, 2017

Java Multithreaded Programming

A program that has two or parts can run concurrently. Each part is a thread. So this is a specialised form multitasking. Process based multitasking is heavyweight and use seperate address spaces. It gives the big picture of the application. JVM has control as it handled by os level. Thread based is light weight and use same address space. So inter communication between threads is easy. This gives detail view of the part it's running. JVM has full control. Multithreading reduces idle time by running another when one is waiting for something like slow network operation. And this avoids application being blocked for something. In a single core CPU no actual parallel threading is happening but CPU time is allocated between threads. Running thread can be suspended and resumed. Can be blocked when waiting. When terminated can't resume. Threads has priorities. Higher priority threads can take cpu power by pushing low or low priority threads can volunteeraly allow if its blocked

Java Head Dump Vs Thread Dump

JVM head dump is a snapshot of a JVM heap memory in a given time. So its simply a heap representation of JVM. That is the state of the objects. JVM thread dump is a snapshot of a JVM threads at a given time. So thats what were threads doing at any given time. This is the state of threads. This helps understanding such as locked threads, hanged threads and running threads. Head dump has more information of java class level information than a thread dump. For example Head dump is good to analyse JVM heap memory issues and OutOfMemoryError errors. JVM head dump is generated automatically when there is something like OutOfMemoryError has taken place.  Heap dump can be created manually by killing the process using kill -3 . Generating a heap dump is a intensive computing task, which will probably hang your jvm. so itsn't a methond to use offetenly. Heap can be analysed using tools such as eclipse memory analyser. Core dump is a os level memory usage of objects. It has more informaiton t