aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/worker/terminate/index.md
blob: 92f8b0d8b15ef401835a3c97b72eea766cf92a1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
title: Worker.terminate()
slug: Web/API/Worker/terminate
translation_of: Web/API/Worker/terminate
---
{{ apiref("Worker") }}

La méthode **`terminate()`** de l'interface {{domxref("Worker")}} termine immédiatement le {{domxref("Worker")}}. Cette interruption ne permet pas au worker de finaliser ses opérations, il est juste arrêté sur le champ.

## Syntaxe

```js
myWorker.terminate();
```

### Paramètres

Aucun.

### Valeur de retour

Néant.

## Exemple

L'extrait de code suivant montre la création d'un objet {{domxref("Worker")}} en utilisant le constructeur {{domxref("Worker.Worker", "Worker()")}}, qui est alors immédiatement interrompu.

```js
var myWorker = new Worker("worker.js");

myWorker.terminate();
```

## Spécifications

| Spécification                                                                                        | Statut                           | Commentaire |
| ---------------------------------------------------------------------------------------------------- | -------------------------------- | ----------- |
| {{SpecName('HTML WHATWG', "#dom-worker-terminate", "Worker.terminate()")}} | {{Spec2('HTML WHATWG')}} |             |

## Compatibilité des navigateurs

{{Compat("api.Worker.terminate")}}

## Voir aussi

L'interface {{domxref("Worker")}} à laquelle elle appartient.