Application Development, Product to Market
  • Home
  • Notes
  • Projects
  • Resources
    • Discovery Log
    • Books I Read
    • Blogs I Visit
    • Tools I Use
  • Home
  • Notes
  • Projects
  • Resources
    • Discovery Log
    • Books I Read
    • Blogs I Visit
    • Tools I Use

Java 1.8 Lambda & Method Reference

2/25/2018

0 Comments

 
One way to create thread is to pass a object that implements Runnable Interface to a Thread constructor as mentioned in Java Multithreading Approaches (Java Concurrency - Part 1):
​public class MyRunnable implements Runnable{
  // this method is called when a runnable thread starts
  public void run(){
    printMessage();
  }
}

public class ThreadDemo{
  public static void main(String args[]){
    Thread t1 = new Thread(new MyRunnable); 
    Thread t2 = new Thread(new MyRunnable);
    Thread t3 = new Thread(new MyRunnable);
    t1.start();    
    t2.start();
    t3.start();

  }

  public static void printMessage(){
    System.out.println("Hello");
  }
}


Read More
0 Comments

Non-Blocking Function (Java Concurrency - Part 3)

7/11/2013

0 Comments

 
With regards to java concurrency, when reading some API documentation (e.g. java.util.concurrent),  there's  the term "non-blocking" and "blocking." In computer science, non-blocking means:

  • Use low-level atomic hardware primitives (machine instructions) such as compare-and-set instead of intrinsic locks to ensure thread safety (data integrity under concurrent access).
  • Performance gain and better scalability. threads does not have to be suspended/waken up by the OS using synchronization.
  • Use non-fair locking (which does not guarantee any particular access order), which can have much more system throughput than fair-locking (which grants access to the longest-waiting thread).
  • It doesn't cause other tasks (threads) to wait until the task is finished.
  • Deadlock free. The risk of deadlocks is removed. No one thread will wait to get a lock held by another thread "forever". 

Read More
0 Comments

ForkJoinPool Example (Java Concurrency - Part 2)

7/10/2013

0 Comments

 
In Java concurrency, ForkJoinPool uses a work-stealing multi-threading framework which works well for executing tasks of uneven distribution of chunk sizes. Before you read on, you need to know Java Multithreading Approaches first.

A ForkJoinPool implements ExecutorService but it differs from other (I'll refer them as 'traditional') ExecutorService mainly by virtue of employing work-stealing - all threads in the pool attempt to find and execute subtasks created by other active tasks. It automatically balance the task load between threads, while traditional ThreadPoolExecutor has no mechanism for such kind of load balancing. If no available worker thread is available, tasks will be blocked until a thread becomes available to steal work from those workers who are busy.

Read More
0 Comments

Java Multithreading Approaches (Java Concurrency - Part 1)

7/7/2013

0 Comments

 
In Java concurrency, there are two low level concurrency implementations in Java to create a thread - extend the Thread class or implement Runnable interface.  These basic approaches neither return value from the thread nor throw exception should anything goes wrong. There's a third approach since Java 1.5 - use Java Concurrency package which supports to receive return values from thread execution.

Read More
0 Comments

    Categories

    All
    Algorithm
    Concurrency
    CQ
    Data Structure
    Design Pattern
    Developer Tool
    Dynamic Programming
    Entrepreneur
    Functional Programming
    IDE
    Java
    JMX
    Marketing
    Marklogic
    Memory
    OSGI
    Performance
    Product
    Product Management
    Security
    Services
    Sling
    Social Media Programming
    Software Development

    Feed Widget

    Archives

    May 2020
    March 2020
    April 2018
    March 2018
    February 2018
    December 2017
    March 2017
    November 2016
    June 2016
    May 2016
    April 2016
    October 2015
    September 2015
    August 2015
    September 2014
    July 2014
    June 2014
    May 2014
    March 2014
    January 2014
    December 2013
    November 2013
    October 2013
    September 2013
    August 2013
    July 2013
    June 2013

    RSS Feed

in loving memory of my mother  and my 4th aunt
Photos used under Creative Commons from net_efekt, schani, visnup, Dan Zen, gadl, bobbigmac, Susana López-Urrutia, jwalsh, Philippe Put, michael pollak, oskay, Creative Tools, Violentz, Kyknoord, mobilyazilar