Understanding Thread Life Cycle, Thread States in Java | Tutorial with Examples
Tutorial explains thread life cycle in Java with examples, Java threads lifecycle diagram, explains individual thread states, Java code example showing a thread moving through its states, logic of Java code example explained through a sequence diagram showing Java thread state transitions.
Top 5 Difference Between Callable and Runnable Interface in Java
A blog about Java, Programming, Algorithms, Data Structure, SQL, Linux, Database, Interview questions, and my personal experience.
How to Implement Double Checked Locking in Java? Example Tutorial
Double checked locking pattern is one of the interesting topics in Java Interviews. Earlier, it was asked to see if a Java developer can write code using a synchronized block or not, and now it asks to gauge the candidate's understanding of concurrency, volatile, and synchronization in Java. One of the simplest ways to write thread-safe Singleton was to make the getInstance() method synchronized but prior to JDK 1.6, a simple uncontented synchronization block was expensive, and that lead…
How to stop a thread in Java? Example
Today we're going to learn about how to stop a thread in Java. It's easy to start a thread in Java because you have a start() method but it's difficult to stop the thread because there is no working stop() method. Well, there was a stop() method in Thread class, when Java was first released but that was deprecated later. In today's Java version, You can stop a thread by using a boolean volatile variable. If you remember, threads in Java start execution from run() method and stop, when it…
Thread-safe Singleton in Java using Double Checked Locking Idiom
Singleton Pattern is one of the famous design patterns from the Gang of Four. Even though nowadays it is considered as an anti-pattern, it has served us well in the past. In Singleton pattern, a class has just one instance throughout its lifetime and that instance is shared between multiple clients. Singleton class has two responsibility, first to ensure that only instance of the class gets created and second, provide a method getInstance() so that everyone can get access to that single…
How to Create and Start Multiple Threads in Java? - Example
Hello guys, Multithreading is one of the biggest strengths of Java, which allows you to divide a task and execute faster by using more than one thread. In order to use multiple threads in Java, you need to first define the task which will be executed by those threads. In order to create those tasks, you can either use the Runnable or Callable interface. If you are just learning Java chose the Runnable interface, it's a simpler one, but if you are familiar with Java multithreading and want to…
Sign in
Javarevisited - Google+
Multitarea e Hilos en Java con ejemplos (Thread & Runnable) - Jarroba
El proyecto de este post lo puedes descargar pulsando AQUI. En esta entrada vamos a ver las diferentes maneras de como trabajar con Threads en Java (o hilos en español). Sino tienes muy claro el concepto de la multitarea te recomendamos que te leas primero la entrada de Multitaréa e Hilos, fácil y muchas ventajas aunque en esta … Continúa leyendo Multitarea e Hilos en Java con ejemplos (Thread & Runnable)
Difference between ExecutorService.submit() and Executor.execute() methods in Java?
Tutorials and Interview questions for Java, data structures, algorithms, programming, coding, FIX Protocol, Tibco RV, UNIX,SQL,books,certifications.
Difference between Executor, ExecutorService and Executers class in Java
Tutorials and Interview questions for Java, data structures, algorithms, programming, coding, FIX Protocol, Tibco RV, UNIX,SQL,books,certifications.