Thursday, October 24, 2024

What is Timer and TimerTask in Java – Tutorial Example

Timer in Java is a utility class that is used to schedule tasks for both one time and repeated execution. Timer is similar to the alarm facility many people use in mobile phones. Just like you can have one time alarm or repeated alarm, You can use java.util.Timer to schedule a time task or repeated task. In fact, we can implement a Reminder utility using Timer in Java and that's what we are going to see in this example of Timer in Java. Two classes java.util.Timer and java.util.TimerTask is used to schedule jobs in Java and forms Timer API. 

4 Reasons and Benefits of Using Multithreading in Java? Why Threads?

In one word, we use Threads to make Java applications faster by doing multiple things at the same time. In technical terms, Thread helps you to achieve parallelism in Java programs. Since CPU is very fast and nowadays it even contains multiple cores, just one thread is not able to take advantage of all the cores, which means your costly hardware will remain idle for most of the time. By using multiple threads, you can take full advantage of multiple cores by serving more clients and serving them faster. Since, in today's fast-paced world, response time matters a lot and that's why you have multi-core CPUs, but if your application doesn't make full use of all resources then there is no point adding them, multi-threading is one way to exploiting huge computing power of CPU in Java application.

4 examples to convert Date to LocalDate in Java 8?

One of the challenge you will face while using new Java 8 Date and time API, JSR-310 in existing Java application is the conversion between java.util.Date and java.time.LocalDate and other classes. Even though library has everything you would expect, it doesn't have a direct conversion method between old Date and new LocalDate. There is a reason for it, eventhough java.util.Date says its a date its not, becuase its just a millisecond value since midnight at the start of 1970 GMT. It's equivalent to Instant class in new Java Date API and that's why you have a direct conversion method between Date and Instant in Java 8. Anyway, its not hard to convert a java.util.Date to java.time.LocalDate in Java 8, in fact there are multiple ways which we will explore in this tutorial. 

Wednesday, October 23, 2024

Difference between ExecutorService.submit() and Executor.execute() methods in Java?

What is the difference between Executor.submit() and Executor.execute() method in Java? This is one of the good multi-threading questions for experienced Java programmers, mostly asked in Investment Banks like Barclays, Deutsche Bank, or Citibank. A main difference between the submit() and execute() method is that ExecuterService.submit()can return the result of computation because it has a return type of Future, but the execute() method cannot return anything because return type is void. The core interface in Java 1.5's Executor framework is the Executor interface which defines the execute(Runnable task) method, whose primary purpose is to separate the task from its execution.

Difference between Process and Thread in Java - Example

One of the common questions from programming interviews is, what is the difference between a Thread and a Process? Well, the main difference between them is that a Process is a program that is executing some code and a thread is an independent path of execution in the process. A process can have more than one thread for doing independent tasks e.g. a thread for reading data from disk, a thread for processing that data, and another thread for sending that data over the network. This technique to improve throughput and better utilize CPU power is also known as multi-threading.

How to use Exchanger for Inter thread communication in Java? Example Tutorial

Hello guys, if you are working in a concurrent Java application then you might have heard about the Exchanger class of java.util.concurrent package. The Exchanger in Java is another concurrency or synchronization utility introduced in Java 1.5 along with CountDownLatch, CyclicBarrier, and Semaphores. As the name suggests, the Exchanger allows two Threads to meet and exchange data at the rendezvous or meeting point. This means you can use Exchanger to share objects between threads and for inter-thread communication. The java.util.Exchanger is a parametric class, which defines and holds the type of object to be exchanged. It has an overloaded method called the exchange(), which is used to exchange objects between threads.

What happens when you call Thread.run() instead of Thread.start() in Java? Trick Interview Question

Hello guys, writing multi-threaded and concurrent programs is not easy, not even in Java.  Even senior developers, including myself, make mistakes while writing concurrent Java applications. This is also one of the trickiest areas of Java programming language, where misconceptions outnumber concepts. Considering the amount of misconception an average Java programmer has about multi-threading and concurrency, I thought to start a new series about common multi-threading mistakes done by Java programmers; what is a better way to learn from common real word mistakes.

How to Implement Thread in Java with Example

How to implement Thread in Java
In my opinion, Thread is one of the most important features of the Java programming language which helped it to become the most popular programming language. I remember, when I first started learning Java in one of the programming classes in India how important Thread was a portrait and how much emphasis is given on a clear understanding of multi-threading. It’s still popular and one of most sought after skills in Java programmer because writing concurrent and multi-threaded applications in Java is challenging, despite Java providing excellent support at language level using synchronized and volatile keyword.

Educative Review - Is Grokking Modern System Design for Software Engineers and Managers worth it?

Hello guys, System Design Interview is one of the hardest part of any coding or programming job interview and it requires a lot of preparation and knowledge to crack system design interview. You need to know a lot of System design concepts like API Gateway, Load Balancer, Microservices vs Monolithic architecture, SQL vs NoSQL, Horizontal vs Vertical scalability and much. If you are preparing for System design interview then you may have come across that Educative.io has one of best System design courses like this one and Grokking the System Design Interview.  Before I give you my verdict on whether you need to choose Educative's Grokking Modern System Design For Software Engineers And Managers course, let me tell you a little bit about what system design really is.

Udemy vs Educative Review? Which is better Website for Beginners?

Hello guys, if you are wondering the difference between Udemy and Educative and whether you should take Udemy courses or join the Educative platform to learn new tech skills, you have come to the right place. Earlier, I have shared a comparison between Pluralsight and Udemy as well as CodeCademy vs Pluralsight in this article, I will compare Udemy with Educative, a new text-based, interactive learning platform. While I have often said that Udemy is my favorite platform because you can get high-quality and comprehensive courses from top instructors for just $9.9, which is phenomenal. 

Can You Learn Coding and Web Development in your 40s and 50s?

Yesterday, I was speaking to one of my friends who were not from a programming background but working as a teacher in a college of Engineering and Technology in the countryside of India. He just turned 40, and he is also the father of two wonderful kids. He has been teaching Maths to B.Tech students in a private engineer college for the last 15 years. He is earning Ok, but he always wanted to explore the world, and he now realizes that a Programming job can provide him that opportunity, so he contacted me to find out whether it's too late for a Programming career.

Monday, October 21, 2024

Review - Is Grokking the Machine Learning Interview on Educative Worth it in 2025?

Hello friends, we are here again today for another exciting topic to discuss. But, today we are not gonna discuss something which is related to Java or any other language or spring boot. Today we are gonna discuss something which is immensely practical and has the potential to land you very high-paying data science jobs.  Today we are gonna review a course that focuses on Machine Learning! Machine Learning is very important when we are considering data science interviews! So what's the wait? Let's start! On Educative.io, there is a great course called Grokking the Machine Learning Interview. It couldn't have come at a better moment, with machine learning expected to be a $3.6 billion business by 2025.

Is Coursera and IBM's Full Stack Software Developer Professional Certificate worth it in 2025? Review

Hello guys, if you are looking for the best full-stack Software developer course or certification on Coursera or you want to join IBM's Full Stack Software Developer Professional Certificate program but are not sure whether it's right for you then you have come to the right place. In this article, we will review IBM Full Stack Software Developer certification on 3 important points, instructor reputation, Coursera structure, content quality, and people's review. This will help you to decide whether this course is right for you or not. 

Review - Is Java Programming & Software Engineering Fundamentals Certification on Coursera worth it?

Hello guys, if you want to learn Java and look for the best Java courses online, you have come to the right place.  Earlier, I have shared the best Java Programming courses, and today, I am going to review Java Programming and Software Engineer Fundamentals course from Coursera. This is one of the top Java courses from Coursera, and more than 180K students have already joined this course. This course is offered by Duke University, and it also offers a certification after completing all modules of the course and doing the project on the final module. While the social proof is enough to join this course, we'll review this course on different parameters like Instructor quality, course structure, content, etc., to help you make an informed decision.

Top 10 Eclipse Plugins for Java and Spring Boot Developers

There is no doubt that Eclipse is one of the most popular IDEs for Java development, and what makes Eclipse great is nothing but Plugins. There are hundreds of Eclipse plugins for different kinds of tasks and integration with other essential tools like there are plugins to download code from Github, SVN, CVS, etc. There are planning to use Maven or Gradle from Eclipse. There are specific plugins for Java development, Python Development, creating Spring-based Java applications and for creating Android apps from Eclipse itself. I have seen productivity improvement by just installing the right kind of plugins.