What is a SynchronousQueue in Java?

  Рет қаралды 29,953

Defog Tech

Defog Tech

Күн бұрын

Пікірлер: 45
@riderprovider6213
@riderprovider6213 6 ай бұрын
If anybody can understand fully the concept shared by all the videos in this Defog Tech channel, I bet he/she will get a package of 20+ LPA. Thank you for putting so many quality Java tutorial videos.
@shellindebted5328
@shellindebted5328 6 жыл бұрын
Sir, i feel fortunate that i came across this video.I thoroughly enjoyed it. Thanks !
@smartstack
@smartstack 2 жыл бұрын
Love your explainations! Have been binge watching!
@rajeevkandpal1880
@rajeevkandpal1880 3 жыл бұрын
Thanks again for explaining complex subjects with lucid simplicity. Please make a video on countdown latch/cyclic barrier and Phaser. thanks
@virtexamit
@virtexamit 6 жыл бұрын
Please do cover difference between LinkedBlockingQueue and ArrayBlockingQueue. Your explanation is very nice. Many thanks for such creative work and appreciated for sharing with all.
@jaime7295
@jaime7295 2 жыл бұрын
The items in one is stored as an array while the other as a linkedlist
@mr.bikashdeka7117
@mr.bikashdeka7117 5 жыл бұрын
@Defog Tech Please explain all the internal implementation of all collection framework
@odilhonislomov8954
@odilhonislomov8954 2 жыл бұрын
Thanks a lot
@theycallme_nightmaster
@theycallme_nightmaster 3 жыл бұрын
Would it be a good idea to use this for collision detection in a game? For example if you only had a render() thread on each object you could use a Queue to block until a collision detection thread picks up the object to be rendered at the perfect time so that the collision detection is happening in the background for the next frame while the current frame gets rendered. Thanks for the video, very helpful!
@Gett37
@Gett37 2 жыл бұрын
Thank you my friend
@alex_stevens
@alex_stevens 6 жыл бұрын
Great explanation
@stefanjankovic8253
@stefanjankovic8253 4 жыл бұрын
You mentioned methods put() and take(). What if I use some loop and use offer() and element() for example? Are they thread safe? Is only take and put thread safe here?
@ShyamSunderReddy-t1s
@ShyamSunderReddy-t1s Жыл бұрын
superb sir
@MegaAnufriev
@MegaAnufriev 6 жыл бұрын
Nice and clear tutorials! Like your channel.
@DefogTech
@DefogTech 6 жыл бұрын
Thank you!
@sharanyarai378
@sharanyarai378 6 жыл бұрын
Since you mentioned blocking queue is thread safe then how many producer/consumer thread can work @ same time? What is thread safety means here?
@DefogTech
@DefogTech 6 жыл бұрын
Thread safety means, in presence of multiple threads doing concurrent access, the days integrity of the queue is not compromised. Blocking Queue will ensure* only one thread gets the value and only one thread is able to put value at a time.. etc.
@vijaymishra4232
@vijaymishra4232 4 жыл бұрын
very nice explanation
@filipfolkesson3865
@filipfolkesson3865 3 жыл бұрын
Here you say that the producer thread becomes blocked, but didn't we state in another video that if the blocking queue was full the rejectionhandler would act accordingly to the specifiec policy?
@tridipchakraborty89
@tridipchakraborty89 9 ай бұрын
That was with respect to a Custom threadpool implemented using an array blocking queue, where if all the the threads were busy and max threadpool size is reached, it will reject new incoming tasks. The rejection handler will then act according to specific policy
@MrMikomi
@MrMikomi 4 жыл бұрын
Very good thanks
@BhawaniSingh-jc7cw
@BhawaniSingh-jc7cw 4 жыл бұрын
Great... Thanks
@Abhishekkumar-ri9wp
@Abhishekkumar-ri9wp 5 жыл бұрын
nice explanation
@shellindebted5328
@shellindebted5328 6 жыл бұрын
May i ask you to provide few use cases of Blocking/Synchronous Queue . it would be of great help.
@DefogTech
@DefogTech 6 жыл бұрын
BlockingQueue is typically used for any problem of type producer consumer (BTW it's also used within Executor service to store tasks). Synchronous queue can be used for rate limiting where in one thread will accept request only after handing off it's task to a worker thread... If worker thread is busy it will have to wait and cannot accept new requests (BTW its also used in Cached thread pool where each new task directly created new thread and task itself is not stored in queue)
@anandkulkarni2111
@anandkulkarni2111 6 жыл бұрын
Syncronized pub sub where a message needs to be distributed in acknowledged manner by handshake from reciever
@TheRoxGo
@TheRoxGo 6 жыл бұрын
very good explanation! thanks
@DefogTech
@DefogTech 6 жыл бұрын
Thank you! I'm glad it helped
@360Legion
@360Legion 6 жыл бұрын
Could you make a video of Linked and ArrayBlockingQueue
@DefogTech
@DefogTech 6 жыл бұрын
Sure, will add to the list, though might take a while. I have many in the queue
@DavisTibbz
@DavisTibbz 2 жыл бұрын
So this is equivalent to go channels
@kostasgkoutis8534
@kostasgkoutis8534 Жыл бұрын
Yeah, kind of, except that this queue can not buffer, can not signal to the readers that the queue is writer is done, no timout, etc. I would look to LinkedTransferQueue for more functionality.
@anandkulkarni2111
@anandkulkarni2111 6 жыл бұрын
I just realized that synchrnous queue can be implemented using exchanger concurrency class producer thread sends data and recieves nothing at exchange method Consumer thread sends nothing and recieves data 🤔
@MrMikomi
@MrMikomi 4 жыл бұрын
Was just wondering about the exchanger class myself
@kfliden
@kfliden 5 жыл бұрын
How does it work if there are multiple producers and consumers?
@DefogTech
@DefogTech 5 жыл бұрын
If there are multiple producer threads, only 1 thread will be allowed to offer/put (which in turn will need to wait for a corresponding consumer thread for hand-off)... rest of the producer threads will wait for their chance (they will be in blocking/waiting state until they get their turn). The constructor allows a fairness boolean value which determines if the waiting producer threads are allowed in first-in-first-out order. Same flow for multiple simultaneous consumers.
@kfliden
@kfliden 5 жыл бұрын
@@DefogTech Great, thanks for the explanation!
@suryanarayansubudhi9439
@suryanarayansubudhi9439 6 жыл бұрын
Please make video on concurrent collection..
@DefogTech
@DefogTech 6 жыл бұрын
Sure, which one?
@suryanarayansubudhi9439
@suryanarayansubudhi9439 6 жыл бұрын
@@DefogTech concurrent hashmap
@DefogTech
@DefogTech 6 жыл бұрын
Cool, will add it to the list
@kannadasans7564
@kannadasans7564 5 жыл бұрын
When to use Synchronous Queue
@DefogTech
@DefogTech 5 жыл бұрын
Its used when 2 threads need to coordinate to hand-over a task/event. In CachedThreadPool its used to submit task (to create new thread). In practical scenarios I have not encountered much use for Synchronous Queue
@mrrishiraj88
@mrrishiraj88 Жыл бұрын
🙏💯👍
@vinitsunita
@vinitsunita 2 жыл бұрын
Awesome explaination
Adder and Accumulator classes in Java 8
9:23
Defog Tech
Рет қаралды 32 М.
ThreadLocal in Java
10:59
Defog Tech
Рет қаралды 188 М.
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 7 МЛН
Long Nails 💅🏻 #shorts
00:50
Mr DegrEE
Рет қаралды 17 МЛН
SIZE DOESN’T MATTER @benjaminjiujitsu
00:46
Natan por Aí
Рет қаралды 3,8 МЛН
#28 - What is PriorityQueue in Java with Examples (using Comparator)
15:38
Naveen AutomationLabs
Рет қаралды 18 М.
Java BlockingQueue
17:48
Jakob Jenkov
Рет қаралды 41 М.
Introduction to CompletableFuture in Java 8
19:34
Defog Tech
Рет қаралды 329 М.
What are Java interrupts?
11:19
Defog Tech
Рет қаралды 57 М.
Phaser vs CountDownLatch vs CyclicBarrier
13:40
Defog Tech
Рет қаралды 77 М.
Concurrency vs Parallelism
8:23
Defog Tech
Рет қаралды 245 М.
Set and HashSet in Java - Full Tutorial
20:43
Coding with John
Рет қаралды 233 М.
why are switch statements so HECKIN fast?
11:03
Low Level
Рет қаралды 428 М.
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 7 МЛН