This article presents an implementation of a tracking thread pool in Java. A tracking thread pool is a usual thread pool that records the task execution statistics like total number of tasks executed, average execution time of tasks and total execution time of all tasks. The default thread pools created by Executors class in Java does not […]
This article shows how to create a deadlock in Java. A deadlock occurs when two threads each hold a lock that the other thread is waiting for. Neither of them can proceed without acquiring the lock held by the other thereby creating a deadlock. To study and analyse a deadlock you should be able to […]
This article shows how to send an email through Gmail in Java. We use the JavaMail API to send email. You can download the JavaMail API jar from here and the reference implementation jar from here. Or if you are using maven then just add the following dependencies in your pom.xml file.
This tutorial shows how to read a file in Java using Scanner class. The java.util.Scanner can parse text from a variety of input sources like String, File, InputStream, System.in etc. and can break the input into tokens as per the specified delimiter. By default, it uses whitespace as the delimiter.