2017-03-17 6 views
0

공유 작업자 예제를 봐야했습니다. 그러나 나는 근로자 대 공유 근로자의 차이를 확인할 수 없다. 공유 작업자 예제 https://github.com/mdn/simple-shared-worker. 누구든지 설명해 주시겠습니까?공유 작업자 란 무엇입니까? 작업자와 공유 작업자간에 다른가요?

+0

나는 이미 그것을 보았다. 하지만 제 질문은 다릅니다. 나의 의심은 현명한 개념이 아니라 현명하다. 공유 된 작업자가 동일한 도메인의 모든 스크립트에 액세스하는 방법은 무엇입니까? – Vasi

+0

안녕하세요, 제 질문은 중복되지만 답변이 다릅니다. 프런트 엔드 개발자로서, 나는이 대답을 안다. 하지만 스택 오버플로에서 링크, 귀하의 제안을 이해할 수 없습니다. 귀하의 링크는 매우 기본적인 정보를 가지고 있습니다. 그래서 저는 많은 링크를 통해 답을 찾아 보았습니다. 답변 탭에서 내 대답을 본 다음 이해하십시오. 당신이 이해할 수없는 경우이 코멘트에 저에게 연락하십시오. – Vasi

답변

-1

작업자 및 공유 작업자 작업 흐름은 다음과 같습니다. 노동자 및 공유 노동자 사이

This image helps to understand working flow and common behavior of Worker and SharedWorker

Difference between Worker and SharedWorker

비슷한 기능을 제공합니다.

The Worker works in another thread. So it's not affecting the main thread. So that time users can scroll, view the page without blocking. 

1. Worker can't access DOM elements from the web page. 
2. Worker can't access global variables and functions from the web page. 
3. Worker can't call alert() function. 
4. Objects such as window, parent, document can't be accessed inside the worker. 

근로자 자신의 기능.

Workers life time between page creates and closure. Once the page creates the new workers will be created. View first image that blog diagram says about Wokers. 

공유 작업자 자신의 기능.

공유 작업자는 모든 도메인의 웹 페이지를 연결합니다. 블로그 다이어그램에서 Wokers vs Shared Workers에 대한 두 번째 이미지를 봅니다.

참조 링크 Workers document