070-480J Free Dumps Study Materials
Question 5: DRAG DROP
HTML5アプリケーションのWebワーカーを作成しています。
Webワーカーでは、次のタスクを実行する必要があります。
Webワーカーのイベントリスナーを登録する
ウェブワーカーの開始と停止
必要なタスクを実行する関数を定義する必要があります。
どのコード行を使用しますか?
(答えを出すには、該当する行を正しい場所にドラッグします。コードの各行は、1回、複
数回、またはまったく使用できません。分割バーをペインの間にドラッグするか、
コンテンツを表示します)。
Correct Answer:* addEventListener
The addEventListener() method attaches an event handler to the specified element.
In context of a worker, both self and this refer to the global scope. The worker can either add
an event listener for the message event, or it can define the onmessage handler to listen for
any messages sent by the parent thread.
* postmessage
Pass a message to the worker.
* close()
Terminating Workers
Workers are resource-intensive; they are OS-level threads. Therefore, you do no want to
create a large number of worker threads, and you should terminate the web worker after it
completes its work.
Workers can terminate themselves, like this:
self.close();
Reference: HTML DOM addEventListener() Method; The Basics of Web Workers