You need to generate threaddump of java based process whenever...
1) JVM refuses to exit cleanly.This could be due to
  a) Some user defined thread running infintely
  b) Some threads getting deadlock
  c) Some threads going in infinite wait state.
2) Application is unresponsive.
3) Application is not behaving as expected.
Friday, October 22, 2010
Tuesday, May 11, 2010
Robert Frost: The Road Not Taken (1915)

Two roads diverged in a yellow wood,
And sorry I could not travel both
And be one traveler, long I stood
And looked down one as far as I could
To where it bent in the undergrowth.
Then took the other, as just as fair,
And having perhaps the better claim,
Because it was grassy and wanted wear;
Though as for that the passing there
Had worn them really about the same.
And both that morning equally lay
In leaves no step had trodden black.
Oh, I kept the first for another day!
Yet knowing how way leads on to way,
I doubted if I should ever come back.
I shall be telling this with a sigh
Somewhere ages and ages hence:
Two roads diverged in a wood, and I--
I took the one less traveled by,
And that has made all the difference.
Monday, April 26, 2010
Hindi translation of Robert Frost's "Woods are lovely dark and deep..." by Harivansh Rai Bachchan

“ The woods are lovely, dark and deep
But I have promises to keep,
and miles to go before I sleep. ”
- Robert Frost
Stopping By Woods on a Snowy Evening
Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.
My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.
He gives his harness bells a shake
To ask if there is some mistake.
The only other sound's the sweep
Of easy wind and downy flake.
The woods are lovely, dark and deep.
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.
“Stopping by Woods on a Snowy Evening” is regarded as Frost's masterpiece.
The speaker, while traveling on horseback (or in a horse-drawn sleigh) on the darkest evening of the year, stops to watch the woods fill up with snow. He thinks the owner of these woods is someone who lives in the village and will not see the speaker stopping on his property. While the speaker continues to gaze into the snowy woods, his little horse impatiently shakes the bells of its harness. The speaker describes the beauty and allure of the woods as “lovely, dark, and deep,” but reminds himself that he must not remain there, for he has “promises to keep,” and a long journey ahead of him.
Below is the the hindi translation of the last stanza of the original master piece by Harivansh Rai Bachchan
गहन सघन मनमोहक वन तरु मुझको आज बुलाते हैं,
किन्तु किये जो वादे मैंने याद मुझे वोह आते हैं,
अभी कहाँ आराम बड़ा यह मूक निमंत्रण छलना हैं,
अरे अभी तो मीलों मुझको , मीलों मुझको चलना ।
Monday, April 5, 2010
Alternative to 'top' command on Solaris
prstat Command:
prstat utility iteratively examines all active processes on the system and reports statistics based on the selected output mode and sort order. The prstat command provides output similar to the ps command.
Options for prstat Command
eg: To find the top 5 process consuming CPU in Solaris
prstat -n 5 -s cpu
Ref: http://docs.sun.com/source/819-1892-12/FMASolarisCmd.html#22021
prstat utility iteratively examines all active processes on the system and reports statistics based on the selected output mode and sort order. The prstat command provides output similar to the ps command.
Options for prstat Command
eg: To find the top 5 process consuming CPU in Solaris

Ref: http://docs.sun.com/source/819-1892-12/FMASolarisCmd.html#22021
Sunday, March 21, 2010
Good Books on Design Patterns
There are different ways in which people appreciate design patterns.
Some do it in extremely theoretical ways while some do it in extremely practical ways.
Some experience an "Aha!" moment when they finally see the great power of the patterns - when they finally realise the exact design patterns which would help them with the task at their work.
Design Patterns help us to welcome change rather than fighting with it.
Finding the right book on the subject is very important.
Below are the four books that I would recommend.
Some do it in extremely theoretical ways while some do it in extremely practical ways.
Some experience an "Aha!" moment when they finally see the great power of the patterns - when they finally realise the exact design patterns which would help them with the task at their work.
Design Patterns help us to welcome change rather than fighting with it.
Finding the right book on the subject is very important.
Below are the four books that I would recommend.
- Design Patterns -Elements of Reusable Object-Oriented Software - GoF -Pearson Education Publication
- Head First Design Patterns- Elisabeth Freeman, Eric Freeman, Kathy Sierra and Bert Bates -O'relliy Publication
- Holub on Patterns-Learing Patterns by Looking at Code -Allen Holub- Apress Publication
- Java Design Patterns-James Cooper-Pearson Education Publication
Why Vector and Hashtable violate the naming convention specified by Java Collection Framework?
Vector and Hashtable were introduced in JDK 1.0 .
The Java Collections Framework was introduced with JDK 1.2.
Due to backward compatiblity issues the names of Vector and Hashtable could not be changed.
Therefore the "table" portion of Hashtable could not have the "t" changed to uppercase "T." In fact, there is a naming convention for implementations and interfaces in the Java Collection Framework and neither
However the
The Java Collections Framework was introduced with JDK 1.2.
Due to backward compatiblity issues the names of Vector and Hashtable could not be changed.
Therefore the "table" portion of Hashtable could not have the "t" changed to uppercase "T." In fact, there is a naming convention for implementations and interfaces in the Java Collection Framework and neither
Hashtable
nor Vector
could be changed to meet this convention. Most implementations in the Java Collections Framework (such as ArrayList
, HashMap
, and TreeSet
) have their name formed from an implementation detail as the first portion of the name and having the name end with the interface implemented.However the
Vector
and Hashtable
classes were retrofitted to be part of this new Java Collections Framework and, as part of this, to implement interfaces from that framework. Vector
was altered to implement List . Simmilarly Hashtable
was altered to implement Map
Monday, January 25, 2010
SocketException in Java
In this post we will look into the details of 2 kinds of SocketException in Java
1) java.net.SocketException: Connection reset and
2) java.net.SocketException: Connection reset by peer: socket write error
1) java.net.SocketException: Connection reset
Occurs when :
While reading from the socket(inputstream)
Occurs where:
Server side or Client side
Reason:
If program(server/client) tries to read data from (client/server) using sockets InputStream and the other side(client/server) has gone down unexpectedly i.e crashed without closing its sockets or OutputStream.
However:
Note if the other(client/server) side closes its socket or related OutputStream (belonging to socket),this exception does not occur at the program(server/client) side.Closing the socket closes all the related output and input streams.
Summary:
If program tries to read from a socket input stream and the other side has gone down(crashed),or thread completes its run without closing the outputstream or socket.
Stack Trace:
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.net.SocketInputStream.read(SocketInputStream.java:182)
at java.io.FilterInputStream.read(FilterInputStream.java:66)
at SocketServerDemo.main(SocketServerDemo.java:27)
---------------------------------------------------------------------------------
2) java.net.SocketException: Connection reset by peer: socket write error
Occurs when :
While writing to the socket(outputstream)
Occurs where:
Server side or Client side
Reason:
If program(server/client) tries to write data to (client/server) using sockets OutputStream and the other side(client/server) has gone down unexpectedly i.e crashed without closing its sockets or InutputStream.
However:
Note if the other(client/server) side closes its socket or related InputStream (belonging to socket), this exception does not occur at the program(server/client) side.Closing the socket in turn closes all the related output and input streams.
Summary:
If program tries to write to the socket's output stream and the other side has gone down(crashed),or thread completes its run without closing the inputstream or socket.
Stack Trace:
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:115)
at java.io.DataOutputStream.write(DataOutputStream.java:71)
at ConnectionResetServerDemo_1.main(ConnectionResetServerDemo_1.java:15)
---------------------------------------------------------------------------------
1) java.net.SocketException: Connection reset and
2) java.net.SocketException: Connection reset by peer: socket write error
1) java.net.SocketException: Connection reset
Occurs when :
While reading from the socket(inputstream)
Occurs where:
Server side or Client side
Reason:
If program(server/client) tries to read data from (client/server) using sockets InputStream and the other side(client/server) has gone down unexpectedly i.e crashed without closing its sockets or OutputStream.
However:
Note if the other(client/server) side closes its socket or related OutputStream (belonging to socket),this exception does not occur at the program(server/client) side.Closing the socket closes all the related output and input streams.
Summary:
If program tries to read from a socket input stream and the other side has gone down(crashed),or thread completes its run without closing the outputstream or socket.
Stack Trace:
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.net.SocketInputStream.read(SocketInputStream.java:182)
at java.io.FilterInputStream.read(FilterInputStream.java:66)
at SocketServerDemo.main(SocketServerDemo.java:27)
---------------------------------------------------------------------------------
2) java.net.SocketException: Connection reset by peer: socket write error
Occurs when :
While writing to the socket(outputstream)
Occurs where:
Server side or Client side
Reason:
If program(server/client) tries to write data to (client/server) using sockets OutputStream and the other side(client/server) has gone down unexpectedly i.e crashed without closing its sockets or InutputStream.
However:
Note if the other(client/server) side closes its socket or related InputStream (belonging to socket), this exception does not occur at the program(server/client) side.Closing the socket in turn closes all the related output and input streams.
Summary:
If program tries to write to the socket's output stream and the other side has gone down(crashed),or thread completes its run without closing the inputstream or socket.
Stack Trace:
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:115)
at java.io.DataOutputStream.write(DataOutputStream.java:71)
at ConnectionResetServerDemo_1.main(ConnectionResetServerDemo_1.java:15)
---------------------------------------------------------------------------------
Labels:
connection reset java,
Exceptions,
SocketException
Subscribe to:
Posts (Atom)