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.
@mahi2082 Жыл бұрын
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); } }
@gulfamhassan46352 жыл бұрын
32:50 you need to use wait and notify method in this scenario
@RainakMajumder2 жыл бұрын
thanks bro
@punyabikash3624 Жыл бұрын
Thank you bro....Excellent its really helpful keep posting 👌👌
@RealSlimShady-um6gf Жыл бұрын
Listening...
@syedmohsin33712 жыл бұрын
Hi.. In cognizant what will be the package for Sr Software Engineer B2 position?
@RainakMajumder2 жыл бұрын
that only HR can tell .. have you got the offer from CTS?? or offer in progress
@murahariraofam64732 жыл бұрын
Were you talking about vert.x??? Did you add this in your resume??
@RainakMajumder2 жыл бұрын
yes in additional skills
@sarojsahoo8763 Жыл бұрын
Thread sleep wont be helpful here , because My Requirement is different here, should go for wait and notify only
@mahaperumal68992 жыл бұрын
How many rounds in Morgan Stanley? I have less knowledge about DSA part so please suggest how to prepare the interview
@abhaykumar-tk9xr Жыл бұрын
At the time of interview, how much experience do you have ?
@RainakMajumder Жыл бұрын
5.6
@mahi2082 Жыл бұрын
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.
@akshaykohale31212 жыл бұрын
Please share some coding questions
@RainakMajumder2 жыл бұрын
sure will do that soon
@RandomRandomReels2 жыл бұрын
experience?
@shubhamjain36662 жыл бұрын
Selected?
@Manish-py3jc2 жыл бұрын
Selected or not??
@RainakMajumder2 жыл бұрын
selected
@madhuryamazumder46312 жыл бұрын
@@RainakMajumder Was this followed by anymore interview rounds?