Skip to main content

Posts

Java Multithreading 2021

Thread Thread Is a subprocess that follows a separate execution path, different stack frame and executes independently but they share the same process resources.  Multithreading is the process of executing one or more threads simultaneously that helps in executing multiple tasks at the same time. Advantages less memory fast efficient Supports multitasking Exception in one thread does not affect the other    Thread lifecycle New Runnable Running Non-Runnable Terminated   Ways to create a thread? Extending Thread class Implementing Runnable class   Thread.start() vs Thread.run() Class java.lang.Thread .start() Creates a new thread and the run() method is executed on the newly created thread. Can’t be invoked more than one time otherwise throws java.lang.IllegalStateException.  Interface java.lang.Runnable.run(), No new thread is created and the run() method is executed on the calling thread itself. Multiple invocation is possible   Constructors of a thread class Thread() Thread(String
Recent posts

JAVA Interview Questions 2021

Inner Class vs Sub-Class Inner class is a class which is nested within another class. It can access all variables and methods in the outer class. A sub-class inherits from another class and can access all public and protected methods and fields in the super class.   Protected vs Default Protected - allow access within the package and any subclass from outside the package. Default - allow access within the package only Default access specifier for variables and method is package protected i.e variables and class is available to any other class but in the same package,not outside the package.   Static To share a method or variable for all objects. cannot override static methods. Even if we try to override static method,we will not get an complitaion error,nor the impact of overriding when running the code. Static methods belong to a class and not to individual objects and are resolved at the time of compilation (not at runtime)   Encapsulation Combining properties and methods in a sin

Installing multiple Java Versions On Linux Mint 20

This is how you should Install multiple Java Versions On Linux Mint 20 using alternatives. Install default java version   apt install default-jdk   Install java 8 apt install openjdk-8-jdk  View isntalled java versions update-java-alternatives --list My out put is two java versions as following java-1.11.0-openjdk-amd64      1111       /usr/lib/jvm/java-1.11.0-openjdk-amd64 java-1.8.0-openjdk-amd64       1081       /usr/lib/jvm/java-1.8.0-openjdk-amd64 Check current version java -version mine is java 11   Change java version update-alternatives --config java and select the required version number All set now can use multiple java versions and switch them easily. Ref: https://techviewleo.com/install-java-openjdk-on-linux-mint/

Minikube Start error

Error nuwans: ~ $ minikube start Starting local Kubernetes v1.9.0 cluster... Starting VM... E0229 06:08:09.490344 5655 start.go:159] Error starting host: Error creating host: Error executing step: Running precreate checks. : We support Virtualbox starting with version 5. Your VirtualBox install is "WARNING: The character device /dev/vboxdrv does not exist.\n\t Please install the virtualbox-dkms package and the appropriate\n\t headers, most likely linux-headers-generic.\n\n\t You will not be able to start VMs until this problem is fixed.\n5.2.34_Ubuntur133883". Please upgrade at https://www.virtualbox.org. Retrying. E0229 06:08:09.490920 5655 start.go:165] Error starting host: Error creating host: Error executing step: Running precreate checks. : We support Virtualbox starting with version 5. Your VirtualBox install is "WARNING: The character device /dev/vboxdrv does not exist.\n\t Please install the virtualbox-dkms package and the appropriate\n\t headers, mo

Spring Microservices in Action - Summary

Java Spring Boot Microservices .............................. Contents 1 ■ Welcome to the cloud, Spring  2 ■ Building microservices with Spring Boot 3 ■ Controlling your configuration with Spring Cloud configuration serve 4 ■ On service discovery 5 ■ When bad things happen: client resiliency patterns with Spring Cloud and Netflix Hystrix 6 ■ Service routing with Spring Cloud and Zuul 7 ■ Securing your microservices 8 ■ Event-driven architecture with Spring Cloud Stream 9 ■ Distributed tracing with Spring Cloud Sleuth and Zipkin 10 ■ Deploying your microservices

How to install ElastAlert on Ubuntu

How to install ElastAlert with Elasticsearch on Ubuntu What is ElastAlert? ElastAlert is a simple framework that alerts when it detects anomalies, spikes, or other patterns of rules from data added in the Elasticsearch. Pre Requirements Tested on ubuntu 18 Elastalert Installation apt update apt install python3-pip pip3 install elastalert pip3 install PyYAML==5.1     Elastalert  Elasticsearch Installation wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0-x86_64.rpm dpkg -i elasticsearch-7.2.0-amd64.deb systemctl start elasticsearch systemctl status elasticsearch Elastalert Setup create /root/emailalerts folder Use further below files to create these files. create /root/emailalerts/config.yaml create /root/emailalerts/rules/auth.yaml create /root/emailalerts/rules/nuwan_2mandata1.yaml elastalert-create-index enter   server: localhost          port: 9200          ssl: f leave rest

Linux Mint Guide

Add Eclipse to the Linux Mint Menu Once you setup eclipse you will notice that you can't find a shortcut in the menu. This is how to fix this. 1. go to desktop 2. click "create new launcher " from the menu 3. Browse to the eclipse sh file & save 4. when you saving, will prompt you to add to menu, click yes 5. check on the menu by typing "eclipse" ...