Blogs

The Executor Framework – Part III

In the Part II of Executor Framework blog post series, I had written about creating cancellable Runnable task and creating Runnable task with a timeout with the help of this framework. I had also written about two submit methods of ExecutorService, which are used to create asynchronous task.

Topics: Runnable Java ExecutorService Callable Multithreading Concurrency API ExecutorService awaitTermination Future submit callable Future Technology

The Executor Framework – Part II

In the Part I of Executor Framework blog post series, I had written how it can be used to create a single worker thread for sequential execution of tasks and create a thread pool of fixed number of threads. In this blog post, I’m writing about the following uses of Executor framework:

Topics: Executor Runnable Java ExecutorService Multithreading Future get timeout Concurrency API Executors Future Technology Future cancel

The Executor Framework – Part I

Multithreading is one of the important features of Java programming language. A thread runs a task and thus multiple threads enable execution of multiple tasks concurrently in a Java application. Prior to Java 5, Thread class was instantiated explicitly to create a thread. The thread pool implementation also was not provided by the API.

Topics: Executor Executors.newSingleThreadExecutor Runnable Java ExecutorService Thread fixed size thread pool single thread executor Multithreading Concurrency API Executors.newFixedSizeThreadPool Executors Technology

Interrupting Threads In Java

In a Java application, a thread may keep waiting for a long time after executing wait() or Thread.join() or by put() or take() methods of a BlockingQueue. We also refer such a thread as a blocked thread since it remains blocked until some operation is performed. Sometimes a thread can also be blocked for a certain time by Thread.sleep(). When a thread is blocked for a long time you may need to take the thread out of the WAITING or TIMED_WAITING state. While writing a Java application, we need to take care that a thread does not remain blocked for too long. The corrective action that needs to be performed in such circumstances depends on the type of task the thread is executing. If the task is cancellable, it is simply aborted and if it is not cancellable then a logic needs to be implemented to enable its execution.

Topics: Java NIO ReentrantLock Runnable Java ExecutorService Callable Thread Multithreading BlockingQueue InterruptibleChannel Future Technology Thread Interrupt

e-Zest Solutions is digital experience engineering company with facilities in the United States (Detroit & San Jose), Germany (Hannover), United Kingdom (London UK) and India (Pune) with global clientele. Our services include custom software development, offshore software development, UX consulting, BigData, Managed cloud Services (Azure & AWS), SharePoint consulting/Migration, Enterprise Java application development, Automated software testing services.