/// <summary>
 /// Remove a running thread
 /// </summary>
 /// <param name="thread">Thread to stop and remove</param>
 public static void EndThread(EZThreadRunner thread)
 {
     thread.Stop();
     lock (singleton.threads)
     {
         singleton.threads.Remove(thread);
     }
 }
        /// <summary>
        /// Begin running a thread. For short, one time background operations, Execute is usually a better choice.
        /// The specified action will be called over and over until EndThread is called.
        /// </summary>
        /// <param name="action">Action to run over and over</param>
        /// <param name="synchronizeWithUpdate">Whether to sync with Unitys update function. Generally you want this to be true.</param>
        /// <returns>Running thread instance. Call EndThread to end the thread.</returns>
        public static EZThreadRunner BeginThread(Action action, bool synchronizeWithUpdate)
        {
            EnsureCreated();
            EZThreadRunner thread = new EZThreadRunner(action, synchronizeWithUpdate);

            lock (singleton.threads)
            {
                singleton.threads.Add(thread);
            }
            return(thread);
        }