Synchronous, Asynchronous

When you send email to 10,000 people and it takes 1second per one email: 1. Synchrnous : It will take 10,000 seconds 2. Asynchronous : It will take less than 10,000 seconds.

When load file, use callback function and Asynchronous concept!

readFile, readFileSync

๊ธฐ๋ณธ์ ์œผ๋กœ ๋…ธ๋“œjs๊ฐ€ ์ถ”๊ตฌํ•˜๋Š” ํ•ต์‹ฌ ์ฒ ํ•™์ด '๋น„๋™๊ธฐ'์ด๋‹ค. ๊ทธ๋ž˜์„œ 'Sync'๊ฐ€ ๋ถ™์–ด์žˆ์ง€ ์•Š์€ ๊ฒƒ๋“ค์€ ๋น„๋™๊ธฐ์ด๋‹ค. ์ž…์ถœ๋ ฅ ๊ฐ™์€ ๊ฒƒ์„ ๋ฐ›์„ ๋•Œ ๋น„๋™๊ธฐ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  'Sync'๊ฐ€ ๋ถ™์–ด์žˆ๋Š” ๋™๊ธฐ๋Š” ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•œ๋‹ค๊ณ  ํ•œ๋‹ค.

  • ์ฐธ๊ณ  Node.js๋Š” single-thread๋กœ ๋™์ž‘ํ•œ๋‹ค.

Last updated

Was this helpful?