Bloomberg LP Interview Question for Financial Software Developers






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

static data can be protected by using it inside a synchronized method.here at a time only one can use the data since locks are put on it exactly like mutex in semaphores.

- saumils1987 August 25, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

what about a global static? do u just declare it as a synchronized variable? is there even such thing called synchronized variable in c++?

- cz September 14, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

global static is like that nobody can change it rather i can be used by many.whereas synchronised method makes variable to be accessed by only one computation at a time like semaphores in operating system,so tha data remains protected. no i dnt think that such methods are there in C++;

- saumils1987 September 15, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

thanks~

i have forgotten lots of c++ specifics... have to pick up the slack

anything declared globally is has the lifetime of the program; declaring a global variable static means it only internal linkage and cannot be accessed from the same translation unit

if ever something global needs to be changed safely, maybe choose singleton pattern with proper multi-threading safety?

- cz September 15, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

thanks~

i have forgotten lots of c++ specifics... have to pick up the slack

anything declared globally is has the lifetime of the program; declaring a global variable static means it only internal linkage and cannot be accessed from the same translation unit

if ever something global needs to be changed safely, maybe choose singleton pattern with proper multi-threading safety?

- cz September 15, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

yes. you can have singleton like pattern for providing one point access and make sure that you use mutex or any other synchronization object for providing multithreading safety.

- Anonymous December 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Something like that:

OurSingleton* GetInstance()
{
      if (pInstance == NULL)
      {
            EnterCriticalSection(&cs);
            if (pInstance == NULL)
            {
                  try
                     {
                      pInstance = new OurSingleton();
                     }
                  catch(...)
                     {
                       // do something
                     } 
            }
            LeaveCriticalSection(&cs);
      }
      return pInstance;
}

- sergey.a.kabanov January 13, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Hi Sergey,
I found an article which says that the double-locking should be avoid. Would you like to check it out?
www dot ibm dot com/developerworks/java/library/j-dcl/index.html

- DavidHo July 06, 2013 | Flag


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