Skip to main content

Posts

Showing posts with the label Java

Exchanger in Java's Concurrent API

The Exchanger class in Java's java.util.concurrent package offers a unique synchronization mechanism for concurrent programming. It facilitates exchange of objects between two threads in a pair , acting as a rendezvous point where both threads must arrive with their respective objects before any actual exchange occurs. Key Concepts: Object Exchange:  Each thread presents an object upon calling  exchange() . When both threads arrive, they exchange their objects and proceed. Synchronization:   exchange()  blocks the calling thread until its partner arrives, ensuring data consistency and preventing race conditions. Bidirectional Queue:  Consider  Exchanger  as a two-slot circular buffer where threads take and put items alternatively. Generic Type:  Accommodates exchange of objects of any type ( T ). Methods: exchange(T object) :  Exchanges the given object with another thread's and returns the received object. Blocks until another thread arriv...

Ask yourself why do you need cloud migration

Before looking to cloud migration various factors need to be verified. Few of the are What is the business gain/value for the migration ? What is the organization goals in terms of cloud migration ? Rough estimation of migration cost vs business value What is the status of product life cycle ? Is it in sunset mode ? What are the COTS products used ? What is the license cost changes after migration if any ? Will you able to provide atleast AS-IS functional and non functional requirements of the application. What is the cloud migration strategy that benefit the clients, application and organization ? How to validate AS-IS functionality after migration. How many types of test cases are there ? Is there any need to create new test cases ? (Devils are in details) What is the level of data confidentiality ? What are the readily available cloud features help to reduce the cost of application ? Is user authn and authz are same after migration ? How to migrate users to new platform ? What is th...
Program to print items in single linkedlist in Pendulum order  Single linked list pendulum in java There are sequence of numbers in a single linked list and display the result in pendulum format Input : 1 2 3 4 5 6 7 8 Output : 1 8 2 7 3 6 5 4 Solution :  https://github.com/Bonu/datastructures/blob/main/SingleLinkedListPendulum.java Below is the manual approach: Input: 1 2 3 4 5 6 7 Iteration 1: 1 2 3 4 5 6 7 Iteration 2: 1 7 2 3 4 5 6 Iteration 3: 1 7 2 6 3 4 5 Iteration 4: 1 7 2 6 3 5 4

jtecbits: Data Structures

Q1. Why should we prefer priority queue over sorted list to handle the high priority tasks in time ? Sol. Sorted list uses full ordering every time a new element is added and worst scenario would be O(n). Priority queue uses partial ordering where it takes O(log n) time. Priority queue will make the high priority elements available on the top of the queue always. For information about full order and partial details please check the discrete mathematics.