스레드

프로세스 내에서 메모리를 공유하는 가장 작은 실행 단위.

A thread is a component of a process. Multiple threads can exist within the same process, sharing resources such as memory, while executing independently. Threads are 'lightweight' because context switching between them is faster than between processes since it doesn't require switching the memory context.

        graph LR
  Center["스레드"]:::main
  Rel_assembly_language["assembly-language"]:::related -.-> Center
  click Rel_assembly_language "/terms/assembly-language"
  Rel_cpu_cache["cpu-cache"]:::related -.-> Center
  click Rel_cpu_cache "/terms/cpu-cache"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 지식 테스트

1 / 1

🧒 5살도 이해할 수 있게 설명

요리사(프로세스) 한 명이 있는 주방을 상상해 보세요. 스레드는 요리사의 손과 같습니다—한 손으로 야채를 자르면서 다른 손으로 수프를 저을 수 있습니다. 두 손 모두 같은 주방(메모리)을 공유합니다!

🤓 Expert Deep Dive

스레드 구현: 사용자 레벨(N:1), 커널 레벨(1:1), 하이브리드(M:N). POSIX threads는 표준 API를 제공합니다. CPython의 GIL은 진정한 멀티스레딩을 방지합니다.

📚 출처