2013-07-15  Ali Anwar  <ali_anwar@codesourcery.com>

        PR threads/13217
        * thread.c (thread_apply_all_command): Check for valid threads
        and thread count.
        (thread_array_cleanup): New struct.
        (set_thread_refcount): New function.
	* include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 22.