Java Engineer
BackendPosted 3 days agovia Himalayas, a remote job board
- Work type
- RemoteIn India, the US, Germany and Singapore
- Experience
- 5+ years
- Pay
- Not listedUsually ₹15 LPABackend, median at 5–9 years, in India (Payscale)
- Posted
- 3 days ago
Skills it mentions
Add your skills to see which ones you have.
About the job
Originally posted on Himalayas
Interested?Java Engineer at SME Careers
Apply on Himalayas (opens in a new tab)The job ad ends here
Interview questions for this job6 with answers, on Java, Spring Boot, REST APIs and 4 more
Interview questions for this job
For the skills the ad mentions: Java, Spring Boot, REST APIs, System design, CI/CD, Test automation and Docker.
What is the difference between Semaphore and Monitor?Java
Semaphore vs Monitor
Both semaphores and monitors are used to solve the critical section problem (as they allow processes to access the shared resources in mutual exclusion) and to achieve process synchronization in the multiprocessing environment.
Monitor type high-level synchronization construct. It is an abstract data type. The Monitor type contains shared variables and the set of procedures that operate on the shared variable.
When any process wishes to access the shared variables in the monitor, it needs to access it through the procedures. These processes line up in a queue and are only provided access when the previous process release the shared variables. Only one process can be active in a monitor at a time. Monitor has condition variables.
Semaphore (
java.util.concurrent.Semaphore) used for limit the number of threads accessing a specific resource. Conceptually, a semaphore maintains a set of permits. Eachacquire()blocks if necessary until a permit is available, and then takes it. Eachrelease()adds a permit, potentially releasing a blocking acquirer. However, no actual permit objects are used; the Semaphore just keeps a count of the number available and acts accordingly.Advantages of Monitors:
- Monitors are easy to implement than semaphores;
- Mutual exclusion in monitors is automatic while in semaphores, mutual exclusion needs to be implemented explicitly;
- Monitors can overcome the timing errors that occur while using semaphores;
- Shared variables are global to all processes in the monitor while shared variables are hidden in semaphores.
Advantages of Semaphores:
- Semaphores are machine independent (because they are implemented in the kernel services).
- Semaphores permit more than one thread to access the critical section, unlike monitors.
- In semaphores there is no spinning, hence no waste of resources due to no busy waiting.
Links
https://www.geeksforgeeks.org/monitor-vs-semaphore/
https://stackoverflow.com/questions/7335950/semaphore-vs-monitors-whats-the-differenceFrom Android Interview Questions (Apache 2.0)
How make spring service thread-safe?Spring Boot
There are several ways, probably too long to list here but here are a few examples:
- Design your beans immutable: for example have no setters and only use constructor arguments to create a bean. There are other ways, such as Builder pattern, etc..
- Design your beans stateless: for example a bean that does something can be just a function (or several). This bean in most cases can and should be stateless, which means it does not have any state, it only does things with function arguments you provide each time (on each invocation)
- Design your beans persistent: which is a special case of "immutable", but has some very nice properties. Usually is used in functional programming, where Spring (at least yet) not as useful as in imperative world, but I have used them with Scala/Spring projects.
- Design your beans with locks [last resort]: I would recommend against this unless you are working on a lower level library. The reason is we (humans) are not good thinking in terms of locks. Just the way we are raised and nurtured. Everything happens in parallel without us needing to "put that rain on pause, let me get an umbrella". Computers however are all about locks when you are talking "multiple things at the same time", hence there are some of us (exceptional people) who are doing their fair share and implementing libraries based on these locks. Most of other humans can just use these libraries and worry not about concurrency. Links
- http://dolszewski.com/spring/spring-bean-thread-safety-guide/
- https://stackoverflow.com/questions/15745140/are-spring-objects-thread-safe
From Java interview (MIT)
HTTP Status Code for "Still Processing"REST APIs
HTTP 202 Accepted (HTTP/1.1)
You are looking for
HTTP 202 Acceptedstatus. See RFC 2616:The request has been accepted for processing, but the processing has not been completed.
HTTP 102 Processing (WebDAV)
RFC 2518 suggests using
HTTP 102 Processing:The 102 (Processing) status code is an interim response used to inform the client that the server has accepted the complete request, but has not yet completed it.
but it has a caveat:
The server MUST send a final response after the request has been completed.
I'm not sure how to interpret the last sentence. Should the server avoid sending anything during the processing, and respond only after the completion? Or it only forces to end the response only when the processing terminates? This could be useful if you want to report progress. Send HTTP 102 and flush response byte by byte (or line by line).
For instance, for a long but linear process, you can send one hundred dots, flushing after each character. If the client side (such as a JavaScript application) knows that it should expect exactly 100 characters, it can match it with a progress bar to show to the user.
Another example concerns a process which consists of several non-linear steps. After each step, you can flush a log message which would eventually be displayed to the user, so that the end user could know how the process is going.
Issues with progressive flushing
Note that while this technique has its merits, I wouldn't recommend it. One of the reasons is that it forces the connection to remain open, which could hurt in terms of service availability and doesn't scale well.
A better approach is to respond with
HTTP 202 Acceptedand either let the user to get back to you later to determine whether the processing ended (for instance by calling repeatedly a given URI such as/process/resultwhich would respond with HTTP 404 Not Found or HTTP 409 Conflict until the process finishes and the result is ready), or notify the user when the processing is done if you're able to call the client back for instance through a message queue service (example) or WebSockets.Practical example
Imagine a web service which converts videos. The entry point is:
POST /video/convertwhich takes a video file from the HTTP request and does some magic with it. Let's imagine that the magic is CPU-intensive, so it cannot be done in real-time during the transfer of the request. This means that once the file is transferred, the server will respond with a
HTTP 202 Acceptedwith some JSON content, meaning “Yes, I got your video, and I'm working on it; it will be ready somewhere in the future and will be available through the ID 123.”The client has a possibility to subscribe to a message queue to be notified when the processing finishes. Once it is finished, the client can download the processed video by going to:
GET /video/download/123which leads to an
HTTP 200.What happens if the client queries this URI before receiving the notification? Well, the server will respond with
HTTP 404since, indeed, the video doesn't exist yet. It may be currently prepared. It may never been requested. It may exist some time in the past and be removed later. All that matters is that the resulting video is not available.Now, what if the client cares not only about the final video, but also about the progress (which would be even more important if there is no message queue service or any similar mechanism)?
In this case, you can use another endpoint:
GET /video/status/123Read the rest at the sourceFrom Software Engineering Stack Exchange: asked by Matthew Haugen, answered by Arseni Mourzenko (CC BY-SA 4.0)
How much downtime does 99.99% availability allow per year?System design
About 53 minutes. For comparison, 99.9% allows about 8.8 hours per year, and 99.999% allows about 5 minutes.
From Grokking System Design (open companion) (CC BY 4.0)
Set a Jenkins job to not to clone the repo in SCMCI/CD
Yes, definitely. I do this all the time. You can specify configuration options for your pipeline and one of them is
skipDefaultCheckout, which causes pipeline to skip the default "Declarative: Checkout SCM" stage.The
skipDefaultCheckoutoption is documented in Pipeline Syntax and here's an example Jenkinsfile showing how to use it:pipeline { agent { label 'docker' } options { skipDefaultCheckout true } stages { stage('commit_stage') { steps { echo 'sweet stuff here' } } } }From DevOps Stack Exchange: asked by Héctor Valverde, answered by burnett (CC BY-SA 3.0)
Have you ever taken the initiative?Behavioural
Employers usually base questions on jobs you have done in the past. This gives you the chance to talk about your experience. For instance, they might ask:
- when have you faced a challenging situation?
- can you tell us about a personal achievement at work?
- have you ever taken the initiative?
- have you ever failed at a task?
Your answers should reflect the skills the employer wants. Be positive and tailor your examples to the job description.
If you don't have much work history, you can use examples from outside of work. You can also use examples from volunteering experience.
Use the STAR method to help structure your answers.From National Careers Service: interview advice (Open Government Licence v3.0)
Similar jobs
- Senior Backend EngineerWeekday, Delhi NCR, on-siteToday
- Backend DeveloperAarvexa, Remote in India +1Today
- Senior Software Engineer - PA183ZoomInfo Technologies LLC, Bengaluru, on-site2 days ago
- Senior Analyst - Actuarial ( Python Developer) Gurgaon (3 to 4 years exp in Automation) - 5 days WFOKipi.bi, Delhi NCR, on-site2 days ago
More like this: Backend developer jobs in India (880) and Remote Backend developer jobs in India (305)



