I think you told read has a lock in concurrent hashmap that's not true , we have lock only on write operations. 😊 , Great job for this video really appreciate.
LibraryMangament system works well using concurrent hash map if you have hash key on starting letter of book name...if multiple theards tries to read and update rack info at a time so it will give error. just think about hash value.
Listening...
Programing:
import java.util.ArrayList;
import java.util.List;
public class PrintingNumberAlaphabetInOrderUsingThreads {
public static void main(String[] args) {
List input1 = new ArrayList();
input1.add("A");
input1.add("B");
input1.add("C");
input1.add("D");
input1.add("E");
List input2 = new ArrayList();
input2.add("1");
input2.add("2");
input2.add("3");
input2.add("4");
input2.add("5");
Operations operations = new Operations();
AlphabeticThread alphabeticThread = new AlphabeticThread(operations,input1);
Thread alphThread = new Thread(alphabeticThread);
alphThread.start();
NumberThread numberThread = new NumberThread(operations, input2);
Thread numThread = new Thread(numberThread);
numThread.start();
}
}
class AlphabeticThread implements Runnable
{
Operations operations;
List input1;
AlphabeticThread(Operations operations, List input1)
{
this.operations = operations;
this.input1 = input1;
}
@Override
public void run() {
synchronized (operations)
{
for(String s: input1) {
operations.updateRecord(s);
try {
operations.wait();
operations.notify();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
class NumberThread implements Runnable
{
Operations operations;
List input2;
NumberThread(Operations operations, List input2)
{
this.operations = operations;
this.input2 = input2;
}
@Override
public void run() {
synchronized (operations)
{
for(String s: input2) {
operations.updateRecord(s);
operations.notify();
try {
operations.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
class Operations
{
public void updateRecord(String output)
{
System.out.println(output);
}
}
I think you told read has a lock in concurrent hashmap that's not true , we have lock only on write operations. 😊 , Great job for this video really appreciate.
Thank you bro....Excellent its really helpful keep posting 👌👌
At the time of interview, how much experience do you have ?
5.6
Hi..
In cognizant what will be the package for Sr Software Engineer B2 position?
that only HR can tell .. have you got the offer from CTS?? or offer in progress
Were you talking about vert.x??? Did you add this in your resume??
yes in additional skills
experience?
Thread sleep wont be helpful here , because My Requirement is different here, should go for wait and notify only
How many rounds in Morgan Stanley? I have less knowledge about DSA part so please suggest how to prepare the interview
Selected or not??
selected
@@RainakMajumder Was this followed by anymore interview rounds?
@@RainakMajumder package
32:50 you need to use wait and notify method in this scenario
thanks bro
Please share some coding questions
sure will do that soon
Selected?
LibraryMangament system works well using concurrent hash map if you have hash key on starting letter of book name...if multiple theards tries to read and update rack info at a time so it will give error. just think about hash value.