Added another thread to test how threads are handled when function exits