Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created June 18, 2014 18:41
Show Gist options
  • Save Fhernd/b388995062c9b242e6a7 to your computer and use it in GitHub Desktop.
Save Fhernd/b388995062c9b242e6a7 to your computer and use it in GitHub Desktop.
Demostracón de creación de nuevo thread.
using System;
using System.Threading;
namespace Recetas.Multithreading.Cap01
{
public sealed class ImpresionNumeros
{
public static void Main()
{
Thread nuevoThread = new Thread (new ThreadStart (ImprimirNumeros));
nuevoThread.Start();
ImprimirNumeros();
}
// Método que se invocará por el thrad de Main, y
// el nuevo que creamos dentro ese mismo método:
public static void ImprimirNumeros()
{
Console.WriteLine ("Iniciando ejecución...");
for (int i = 1; i < 10; ++i)
{
Console.WriteLine (i.ToString());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment