﻿using System;
using System.Threading;

namespace Cocurrency
{
    /// <summary>
    /// we should move the exception handler into the Go method
    /// we need an exception handler on all thread entry methods in production application
    /// </summary>
    public class ExceptionHandling : IExample
    {
        /// <summary>
        /// can't catch the exception thrown by Go
        /// due to the new thread is executed in an independent path
        /// </summary>
        public void Run()
        {
            try
            {
                new Thread(Go).Start();
            }
            catch (Exception ex)
            {
                Console.WriteLine("exception");
            }
        }

        private void Go()
        {
            throw null;
        }
    }
}
