Win a copy of Rust Web Development this week in the Other Languages forum!

Vinney Shanmugam

Ranch Hand
+ Follow
since Aug 27, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vinney Shanmugam

Thanks you all for the wonderful replies....
Try TimerTask class of java.util
Hi Peter,

Thanks for the sample code. That's what I exactly wanted to write and didn't think of Thread.yield(). Your code solved my problem and cleared the air.



Thanks.
If a singleton is not thread safe, and two threads enter getInstance() at the same time, there are chances for getting two different objects, provided getInstance() is not synchronized. Is this true first of all. If so, how to recreate it? I did try with the below program,



and didn't see two different objects created,

Output is:
======
method in singleton class test.threads.SingleTonThreads@a90653
method in singleton class test.threads.SingleTonThreads@a90653
I am travelling to UK in couple of months and got 4 year experience. What is salary p.a that i might expect from my employer. Anyone travelled can throw somelight on this please...
11 years ago
I did see the comment " * Causes this thread to begin execution; the Java Virtual Machine
* calls the <code>run</code> method of this thread.
*

"

I too guessed that run() should be called from native. But can't let my hypothesis remains, without confirmation. Thanks for the reply.

11 years ago
Thread is implementing Runnable interface. But i dont understand your point here.

I did check start() API of Thread class and dont see any run() getting called in it. It calls some native methods only.

Can please explain, what are you trying to say?
11 years ago
To run a thread, we need to call start(). So run() method gets executed. But how it is accomplished?

I dont see any run() called from start() when i checked Thread.start() method implementation.

Actually, what happens when Thread.start() is executed by JVM, behind the scenes?
11 years ago
Thanks fred and Rob. That cleared lot of air.
11 years ago
Thanks sheriff.
So, how can we say this as "Open for extension" and "closed for modification"?
I have got some idea but still not clear of the central meaning. Appreciate your help on this with some small examples...
11 years ago
Hi ROb,

Thanks for the reply. But i dont understand your reply. What is the point it's driving?

I just want to realize the benefits of this.... Can someone elaborate it bit more please......
11 years ago
I know this means,

Map m = new HashMap()

and down the line, I can change HashMap to TreeMap(). But this requries code change(even if it is one line) I really think there should be more meaning to this quote, which i dont know..

Please can someone let me know, the power behind and the real meaning behind this???
11 years ago
Which collection can be used to implement Least Recently Used cache in java?

We can use LinkedHashMap. I dont have a justification for this. Can someone help me understand this clearly?
11 years ago
What is the difference between them? Synchronized block do a better performance than methods. Please throw some light on this.....
So, object lock is a sort of a flag which will be checked only when synchronized keyword is used in the code?

I thought, the whole object is locked/encapsulated from access for some time.