Logo

Who is talking?

Archive

Divide and Conquer by Java Threads

over 5 years ago | Subodh Gupta: Subodh's Blog

Suppose you have task which collects the data the from various sources and creates a Object containing all this information e.g. information is distributes over various databases, websites and some you need to calculate based on that data. The single threaded application works fine with small amount of data however as data starts growing single threads shows its limitation.There is a interesting property of threads which comes to our rescue. Thread maintains the private copy of object on which it operates called as working copy in which it keeps the local modification which are made to the object. While main memory contains the master copy of every object.After all threads stop executing all the working copies are merged into the master copy. This becomes the curse in case of multiple objects modify the same field in the object because merging back creates the confusion and results in a unpredictable behavior. However if each thread works on the different field of the object merging won't cause a conflict and hence state remains consistent and predictable.This improves the performance many folds and hence application gain scalability which was missing in the single threaded application.Snippet:import java.util.ArrayList;import java.util.List;public class Test {    public static void main(String[] args) {        final List list = new ArrayList();        Person person = null;        for (int i = 0; i < 100; i++) {            person = new Person();            Runnable runnable = createFirstRunnable(person);            Runnable run = createSecondRunnable(person);            Thread thread = new Thread(runnable);            Thread tt = new Thread(run);            thread.start();            tt.start();            list.add(person);        }        for (Person p : list) {            System.out.println("This is " + p.getFirstName() + " " + p.getLastName() + "'s Blog.");        }    }    private static Runnable createSecondRunnable(final Person person) {        Runnable run = new Runnable() {            @Override            public void run() {                person.setLastName("Gupta");            }        };        return run;    }    private static Runnable createFirstRunnable(final Person person) {        Runnable runnable = new Runnable() {            @Override            public void run() {                person.setFirstName("Subodh");            }        };        return runnable;    }    private static class Person {        private String firstName = null;        private String lastName = null;        public Person() {        }        public String getFirstName() {            return firstName;        }        public void setFirstName(String firstName) {            this.firstName = firstName;        }        public String getLastName() {            return lastName;        }        public void setLastName(String lastName) {            this.lastName = lastName;        }    }}

Sachin Tendulkar's longevity

over 5 years ago | Prasoon Sharma: Enterprise Software Doesn't Have to Suck

There have been over 3300 cricketers who've played Test and One Day cricket. The youngest player was 14 years old Hasan Raza from Pakistan who played 5 ODIs and 2 Test matches at that age. The oldest player was 52 years old W Rhodes from England, who played 8 Test matches at that age. But they are not the ones who've played the game for the longest time. Sachin Tendulkar has. Sachin started international cricket early and is still playing the game as a 38 year old (not many 38 year olds find a spot in international cricket these days). He has played a lot of Test and One Day cricket matches all these years, and has performed well consistently. As a result, he has broken all batting records in cricket. It is unlikely that any other cricketer will break Tendulkar's batting records anytime soon. Sachin's international cricket career spans 21 years and counting. What an athlete!1) Tendulkar entered the game at the youngest age (debut at 16). Very few cricketers start their international career at that age. He is the 3rd youngest to play the game.2) Tendulkar is now 38 years old and still strong. I wish he plays the game for at least another couple of years. The only other cricketers who comes close to his tenure are Javed Miandad from Pakistan (tenure 21 year, debut at 17 and retired at 38) and Sanath Jayasuriya (tenure 20 year, debut at 20 and retired at 40).3) Tendulkar is now 38 years old and like his peers, he has reduced the number of games he plays. But unlike his peers he's still going strong. His peers seem to be headed towards retirement (see how Ponting's performance is dropping in Test and One day cricket - Runs scored and Scoring rate). Tendulkar is exceptional. He beats the rules (normal distribution for statisticians) and sits at the edge of all distributions - debut age,  tenure and performance. When he decides to retire, he will be on the edge of retirement age distribution curve as well.

Carson's Law

over 5 years ago | Lalatendu Das: Interpretations of technorealism

Learnt something new about modern day innovation.Carson's Law (by Curtis Carlson, the C.E.O. of SRI International, in Silicon Valley) states:“In a world where so many people now have access to education and cheap tools of innovation, innovation that happens from the bottom up tends to be chaotic but smart. Innovation that happens from the top down tends to be orderly but dumb.”As a result, says Carlson, the sweet spot for innovation today is “moving down,” closer to the people, not up, because all the people together are smarter than anyone alone and all the people now have the tools to invent and collaborate.My 2 cents:Modern day leadership is all about creating a conducive environment where the bottoms up innovations are encouraged and validated real time. thoughts?