• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

What is Asynchronous?

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Before we talk about asynchronous, let’s first understand synchronous. Imagine you're cooking a simple meal, and you're following these steps:

? Dish 1: Boiled egg and toast


Method: Synchronous

Dish: Boiled egg and toast


  1. Boil water.
  2. Wait until it boils.
  3. Put egg in. Wait 10 minutes.
  4. Take egg out.
  5. Toast bread.
  6. Serve

It’s straightforward, linear, and simple. You’re doing one thing at a time, step-by-step. For this kind of meal, it works fine.

But what happens when you’re making a more complex dish like the one with many ingredients, longer prep, and multiple processes?

Let's look at below example to compare another dish cooked in both synchronous and asynchronous way.

? Dish 2: The Complex Meal


Method: Synchronous

Dish: Pasta with garlic bread


?‍? "I can only do one thing at a time. I must wait for each task to finish before moving on."

  1. Boil water
  2. Cook pasta after water is boiled
  3. Chop vegetables after pasta is cooked.
  4. Roast vegetables
  5. Prepare sauce ingredients after roasting is done.
  6. Cook sauce
  7. Slice and toast garlic bread after sauce is done.
  8. Pasta is done, sauce is ready, veggies are roasted → plate everything hot at the same time.

⏱ Total time = Long
You end up wasting a lot of time just waiting, even though there are tasks that could have been done in parallel.

? Dish 2: The Complex Meal


Method: Asynchronous

Dish: Pasta with garlic bread


?‍? "While something is cooking or waiting, I’ll prep or cook something else"

  1. Start boiling the water.
  2. While waiting for it to boil, chop the vegetables.
  3. Put the vegetables in the oven to roast
  4. While they roast, start mixing the sauce ingredients.
  5. Once the water boils, cook the pasta while the sauce simmers.
  6. Toast the garlic bread while the sauce finishes and veggies roast.
  7. Pasta is done, sauce is ready, veggies are roasted → plate everything hot at the same time.

⏱ Total time = Much shorter

StyleWhoDescription
SynchronousA beginner cooks (maybe you?)Cooks one thing at a time, step-by-step. Simple but slow.
AsynchronousYour mom in the kitchen ?Juggles multiple things at once. Efficient and experienced.
So, what is asynchronous?


This is how asynchronous works. It doesn’t pause everything just because one task takes time. Instead, it allows your program to continue doing other work while waiting for a task to complete thus making the performance more efficient and faster.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу