hilo#

Inicializando la clase de hilo#

Un hilo se crea utilizando el siguiente constructor:

The thread constructor creates a thread object with a callback function to be executed when the Thread is invoked.

Parámetro

Descripción

callback

Una función previamente definida que se ejecutará como punto de entrada cuando se invoque el hilo.

// Define the function "threadPrint".
void threadPrint(){
  Brain.screen.print("Printing!");
}
int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // Construct a thread "Thread" with the
  // thread class.
  thread Thread = thread(threadPrint);
}

This Thread object will be used in all subsequent examples throughout this API documentation when referring to thread class methods.

Métodos de clase#

get_id()#

The get_id() method returns the ID of the tread.

Devuelve: Un número entero que representa el ID del hilo.

join()#

The join() method waits for the other thread to finish its execution.

Devoluciones: Ninguna.

detach()#

The detach() method permits the thread to execute from the thread handle.

Devoluciones: Ninguna.

joinable()#

The joinable() method returns if a thread is joinable.

Devuelve: Un valor booleano que representa si se puede unir un hilo.

interrupt()#

The interrupt() method stops the thread.

Devoluciones: Ninguna.

interruptAll()#

The interruptAll() method stops all threads except main.

Devoluciones: Ninguna.

setPriority()#

The setPriority(priority) method sets the priority of the thread as an integer.

Parámetro

Descripción

prioridad

Un entero que representa la prioridad del hilo.

Devoluciones: Ninguna.

priority()#

The priority() method returns the priority of the thread as an integer.

Devuelve: Un entero que representa la prioridad del hilo.

hardwareConcurrency()#

The hardwareConcurrency() method returns the number of concurrent threads supported by the hardware.

Devuelve: Un número entero que representa la cantidad de subprocesos simultáneos admitidos por el hardware.