This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!

Ravi Desigan

Ranch Hand
+ Follow
since Jan 06, 2017
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ravi Desigan

Campbell Ritchie wrote:Congratulations on the job

Appreciate it!
1 year ago

Jeanne Boyarsky wrote:Guys - relax.

Ravi: Something missing from your list is soft skills. Reviewing projects you worked on in the past so you can talk about what it was like working with teammates, problem solving, etc.

Thanks, Jeanne. Agree, there is really more to the list I formulated in the OP, and your suggestion is valid indeed!

In the meantime, I am back into the *workforce* myself found a good job. The interview process included writing code on the spot for smaller problems (about a dozen of them) and preparing ahead by practicing coding skills in sites such as 'HackerRank' had been helpful!
1 year ago
What are you? Some kind of a "rudeness incarnate"?

You are not a better judge of what happens to me or anyone, when the attitude problem lies in you more than others.

In my experience so far, you have contributed nothing to any of my questions, other than pointing errors.

Anyway, adios to you.
1 year ago

Please don't get me wrong. I'm sure being a knowledgeable and helpful person in here gives you a definite advantage in expressing what you opine about a post. But that does not mean every opinion of ours is correct. I have expressed nothing in bad taste and the use of bold letters is just for the technology names. And you mention about writing 'real code'. That is exactly what I mean by saying upload code in GitHub repo. I was not aware someone could not understand that!

1 year ago
Writing this in a bit of frustrated but yet 'wanting to be helpful' mode myself -

Following is the list of things I am currently considering for my employement, after a career break:

1. Master about 250+ interview questions on various topics (example: JSP, SERVLET, STRUTS, HIBERNATE, SPRING, CORE JAVA, COLLECTIONS, THREADS, STRING, JAVASCRIPT, etc). Revise them *every week* so as to stay prepared as interview could happen the next day!

2. Procure several certifications on hot JAVA skills (could be CLOUD computing, CORE JAVA programmer/developer, etc).

3. Code and create a repository at GITHUB and update resume highlighting this link.

4. Freelance.

5. Practice about 10 programming and 10 SQL assignments as frequently as possible (every day or alternate day is best), as some interviewers ask you to code as part of screening interviews (recently a company asked me to code checking for Palindrome, factorial, etc). There are some sites on the net that could be reached for this purpose - they provide the assignments.

What else?
1 year ago
@Tim, nice to know the difference between polling and interrupts. Although I do not understand the example you have presented. I appreciate your help.

@Rob, the onMessage is implemented by a separate class (that implements messageListener interface) and it is registered with the while (true) thread as its listener for a specific queue in case a message arrives. So that is there connection.

My question is, in case this while (true) and sleep thread does not poll, in that case, is it getting interrupted when onMessage() callback gets triggered?

Someone asked me in a recent interview about the JMS architecture for asynchronous message process. My memory was vague at that time and I said that the receiver polls. He immediately said "No".

Now I am referring to articles all over the net, none of it explains exactly what happens when the message arrives - they only explain how to set up the code.

I am giving the code just in case:

The following is the class implementing messageListener interface:

This class is the thread (the receiver) of the JMS queue messages:

Of course in the above receiver class, the while (true) is not coded (the lines of code following the //Consumer comment) but the thread goes to sleep. Now when onMessage() of this thread registered listener class gets triggered, how does this thread respond? Does it get interrupted? And what does it do, if another message arrives while this thread is processing the current message in its onMessage()?


Tim Holloway wrote:

Claude Moore wrote:I wonder if using an endless loop in the presence of a JMS listener is or not a good practice, since the listener is awakened by the JMS machinery every time a message is send to a queue or to a topic.
I'd bet "no".

I had misgivings about that too. These days, polling is usually not the preferred option. It's extra overhead and it can result in delays in processing while the thread waits to wake up.

But that's a valid poll loop, anyway. The ones you DON'T want use a counting loop instead of a sleep delay.

Hello Tim,

You have mentioned about a process that I precisely have question about. Will you please help me understand the following?

1. What happens to the polling thread when a message arrives (and onMessage() of the listener gets triggered)? Does it get interrupted and throw an interrupted exception?

2. Does the polling thread actively look for message or the arrival of message triggers the thread to wake up and do some processing?

I thank you for your earlier reply regarding the while (true) condition.

I have a basic question on JMS architecture.

On the receiving end, we look up for the connection factory by name, get a connection, procure a Queue session object, then look for the Queue by name, create a receiver providing this queue name to the session object and register a listener with the session.

So this listener implements the message listener interface so that the onMessage() event is triggered automatically when a JMS message arrives at the specified queue.

But, in the receiver class (which does the above sequence of procuring a session object and registering a listener to the specified queue), I see this while loop coded:

while (true)


My question is, what does this while(true) condition stand for? Next, what way the onMessage() of the listener is related to this Thread.sleep process? I'm not getting the actual sequence. Can someone please explain.


Tim Cooke wrote:Have another look at the requirements and tell me how many grade categories are specified?

* A score in the top 20% of all scores is an A.
* A score in the next 20% of scores is a B.
* A score in the next 20% of scores is a C.
* A score in the next 20% of scores is a D.
* A score in the bottom 20% of scores is an F.

I count 5. A, B, C, D, and F.

How many does your code have?

OH...............! I see my mistake. I just assumed the examiner made a mistake in omitting grade E earlier. Feeling silly!
1 year ago
I don't think there is a way to cut-short the logic from the way I have implemented... which is why I posted this question.

If anyone can write it in a better way, they can definitely show it to me, I truly welcome it.

Even if it is not the entire code, but just part of the code that could be bettered, I would be happy to hear it.
1 year ago
The logging classes (log4j, etc) are Singleton.

The database connection classes are singleton.

Thread pooling classes are singleton.
1 year ago

Liutauras Vilda wrote:1. After you get all code working, the other problem might be that you haven't demonstrated any written tests for your code. Have you got them? If no, you can not state your code works and gives correct answer.


Ravi Desigan wrote:fetchNperformersFromMasterList method does the core functionality

instructions wrote:Write a function that takes an arbitrary (possibly unsorted) score list...

You don't have any method which would take List as an argument. For some reason you assumed list must be an ArrayList. Which is not what is specified. Plus you added some extra parameter.

Some of the things you need to take from this interview are:
  • Need to do exactly what is asked, no more - failed on that
  • Code must be tested, proof provided - failed on that
  • Code must be readable - failed on that
  • Code must be well formatted, formatting consistent - failed on that

  • This code is over-complicated. You were asked to write a function/method, one in total, which is accessible to the wide world, meaning one public function and the rest methods private which would serve as helper methods.

    3. Less than optimum outcome is also an outcome - so try to take as much as you can from it. I assume it was home interview exercise, meaning you had fair amount of time, so you had to come up with much more solid solution and code in general.

    Yes, I agree -- I can see that they wanted a method that takes the list alone as you specify whereas in my case, I have an arraylist and several other parameters too! I completely missed this point! Thanks for that.
    1 year ago

    Campbell Ritchie wrote:

    Ravi Desigan wrote:. . . . The specification mentions Grades A through F.

    Not in what you quoted; there is no E.

    . . . If there are two (or more) scores that are identical, then those identical numerical scores must always receive the same grade, . . . .

    Where have you implemented that part?


    Within the method fetchNperformersFromMasterList, I have implimented the duplicate check logic.

    That is, given a sorted list of numbers, for example, 92, 91, 89, 87, the method would look for the ending number, in this case, 87 in the remaining master list... and it will loop through until dups are found. It will count the number of dups (87) in the masterlist, count these duplicates, and add that many 87's to the first list and subtract (remove) them from the masterlist.
    1 year ago

    Tim Cooke wrote:They do have a point.

    Answer me this: To split up a list of items into separate buckets where each bucket contains 20% of the items in the original list, how many buckets would you require?

    Then answer me this: How many buckets (grades) does your code have?

    Have you spotted where you went wrong yet?

    Honestly not sure what is wrong with my code still...

    Is it ok if I submit my email here? (If someone cannot post an answer here, I welcome them to write to me in privacy.)

    I truly appreciate your input of time to clarify things to me.  
    1 year ago