Highbridge Capital Interview Question for Java Developers


Team: Risk Metrics
Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
0
of 0 vote

volatile is applied on variable which is shared between different threads. this keyword make sure that thread doesn't not cache the value of variable and get most updated value every time.

- Amit July 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Volatile keyword is maily used so that Threads using the variable with volatile keyword will always have the latest /updated value of the variable.

- sarthakiter July 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Volatile keyword asks compiler not to do any optimization during the prepossessing as its value can change any time during execution.

- Avi July 27, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Answers (including the book) that say volatile is related to threading are wrong. They're what most people think (possibly including your interviewer), but they're wrong.

Volatile was created in order to handle memory-mapped I/O. For example, the compiler is not allowed to remove redundant stores to the same address since the redundant stores may have meaning to I/O subsytems.

Volatile is neither necessary nor sufficient to handle values accessed from multiple threads.

It's not necessary because it can produce far more memory accesses than is necessary since the complier is not allowed to do much. Using, for example, pthreads you can get the consistency guarantees you need with far less memory traffic.

It's not sufficient because the standard doesn't require it. The C standard says nothing about threads. Modern CPU architectures have a very complicated memory ordering models in order to eek out performance and those models require the use of memory barrier instructions to guarantee cross-thread visibility semantics. pthreads guarantees memory barriers, volatile doesn't.

- smparkes@smparkes.net August 16, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More