# run_threads

**Descripción**

Ejecutar una función dada para una lista de elementos dada en un número dado de hilos

**Parámetros**

<table border="1" id="bkmrk-module-acepta-el-tip" style="width: 562px; height: 162px;"><tbody><tr style="height: 29px;"><td style="width: 112px; height: 29px;">**Nombre**</td><td style="width: 70px; height: 29px;">**Tipo**</td><td style="width: 88px; height: 29px;">**Requerido**</td><td style="width: 292px; height: 29px;">**Descripción**</td></tr><tr style="height: 46px;"><td style="width: 112px; height: 46px;"><div><div>max_threads</div></div></td><td style="width: 70px; height: 46px;">int</td><td style="width: 88px; height: 46px;">SI</td><td style="width: 292px; height: 46px;">Número de hilos </td></tr><tr style="height: 29px;"><td style="width: 112px; height: 29px;">function</td><td style="width: 70px; height: 29px;">callable</td><td style="width: 88px; height: 29px;">Si</td><td style="width: 292px; height: 29px;">Función a ejecutar</td></tr><tr style="height: 29px;"><td style="width: 112px; height: 29px;">items</td><td style="width: 70px; height: 29px;">list</td><td style="width: 88px; height: 29px;">Si</td><td style="width: 292px; height: 29px;">Lista con los items que se asignaran a cada hilo</td></tr><tr style="height: 29px;"><td style="width: 112px; height: 29px;"><div><div>print_errors</div></div></td><td style="width: 70px; height: 29px;">bool</td><td style="width: 88px; height: 29px;">No</td><td style="width: 292px; height: 29px;">Para pintar error por salida</td></tr></tbody></table>

**Return**

<table border="1" id="bkmrk-module_xml-m%C3%B3dulo-en" style="width: 557px;"><tbody><tr><td style="width: 66px;">bool</td><td style="width: 491px;">Devuelve True si no ha habido errores en la ejecución y 0 de suceder lo contrario.</td></tr></tbody></table>

<div id="bkmrk-"></div>**Versión**

- 1.0.0

**Ejemplo**

```
import pandoraPlugintools as pt

# Define a function to be executed in each thread
def process_item(item):
    # Perform some processing on the item
    print(f"Processing item: {item}")

# List of items to process
items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# Number of threads to use
max_threads = 3

# Run the function for each item using multiple threads
success = pt.run_threads(max_threads=max_threads, function=process_item, items=items, print_errors=True)

if success:
    print("All threads executed successfully.")
else:
    print("Errors occurred during thread execution.")
```