Skip to content

Instantly share code, notes, and snippets.

View raghul1212's full-sized avatar

Ragul raghul1212

View GitHub Profile

Get Orders API

Endpoint

GET /api/v1/orders

Description

Fetches a list of orders from the system.
No authentication is required.


Feature Runnable Callable
Return Value void—cannot return any value Generic type T—can return a result
Exception Handling Cannot throw checked exceptions (only runtime exceptions) Can throw checked exceptions
Functional Method public void run() public T call() throws Exception
Integration Works with Thread and Executor Works with ExecutorService and returns a Future
Use Case Fire-and-forget tasks where no output is required Tasks that need a computed result or proper error signal
Feature Deadlock Starvation
Definition A situation where two or more processes are waiting indefinitely for resources held by each other, and none can proceed. A situation where a process waits indefinitely because higher-priority processes continuously consume the resources it needs.
Cause Circular wait among processes for resources. Low-priority process keeps getting preempted by higher-priority processes.
Occurrence Happens due to mutual exclusion, hold-and-wait, no preemption, and circular wait conditions. Happens due to scheduling policies that favor certain processes (e.g., priority scheduling).
Resolution Requires deadlock handling techniques like deadlock prevention, avoidance, detection & recovery. Can be resolved by using aging (gradually increasing priority) or fair scheduling.
Example Process P1 holds resource R1 and waits for R2, while P2 holds R2 and waits for R1 → both wai
Checked Exception (Compile-time Exception) Unchecked Exception (Runtime Exception)
The intent is to ensure that developers explicitly consider and handle the potential error conditions, leading to more robust and reliable code. An unchecked exception occurs during execution of the program, typically caused by programming errors or logical flaws.
It’s a type of exception that should be either handled using a try-catch block or declared in the method’s throws clause. Unlike the checked exception, this exception is not intended to be handled or declared in the method’s throws clause. However, a try-catch block can be used to handle any runtime exceptions that are expected to occur and prevent our program from crashing.
This exception will occur during the compiling time of your program. This exception will occur during the execution of your program.
The Exception class and all its subclasses are compile-time exceptions. If you want to create a custom compile-ti