re-enable styling using the new "set style tui-current-position"
   command.
 
+* New convenience variable $_inferior_thread_count contains the number
+  of live threads in the current inferior.
+
 * New commands
 
 maintenance set ignore-prologue-end-flag on|off
 
 @samp{$_gthread} contain, respectively, the per-inferior thread number
 and the global thread number of the current thread.  You may find this
 useful in writing breakpoint conditional expressions, command scripts,
-and so forth.  @xref{Convenience Vars,, Convenience Variables}, for
-general information on convenience variables.
+and so forth.  The convenience variable @samp{$_inferior_thread_count}
+contains the number of live threads in the current inferior.
+@xref{Convenience Vars,, Convenience Variables}, for general
+information on convenience variables.
+
+When running in non-stop mode (@pxref{Non-Stop Mode}), where new
+threads can be created, and existing threads exit, at any time,
+@samp{$_inferior_thread_count} could return a different value each
+time it is evaluated.
 
 If @value{GDBN} detects the program is multi-threaded, it augments the
 usual message about stopping at a breakpoint with the ID and name of
 @item $_gthread
 The global number of the current thread.  @xref{global thread numbers}.
 
+@item $_inferior_thread_count
+The number of live threads in the current inferior.  @xref{Threads}.
+
 @item $_gdb_major
 @itemx $_gdb_minor
 @vindex $_gdb_major@r{, convenience variable}
 
        {$_thread = 0} \
        {$_gthread = 0} \
        {$_inferior = 1} \
+       {$_inferior_thread_count = 0} \
        {$_exception = <error: No frame selected>} \
        {$_probe_argc = <error: No frame selected>} \
        {$_probe_arg0 = <error: No frame selected>} \
 
     info_threads "" "1"
 
     gdb_test "thread" "Current thread is 1 .*"
+
+    gdb_test "print \$_inferior_thread_count" " = 1"
 }
 
 # "info threads" while there are multiple inferiors should show
     gdb_test "inferior 2" "Switching to inferior 2 .*" "switch to inferior 2"
     gdb_test "file ${binfile}" ".*" "load file in inferior 2"
 
+    gdb_test "print \$_inferior_thread_count" " = 0" \
+       "no threads before we start the second inferior"
+
     runto_main
 
+    gdb_test "print \$_inferior_thread_count" " = 1" \
+       "no other threads started yet"
+
     # Now that we've added another inferior, thread IDs now show the
     # inferior number.
     info_threads "" "1.1 2.1" \
     gdb_breakpoint "thread_function1"
 
     gdb_continue_to_breakpoint "once"
+    gdb_test "print \$_inferior_thread_count" " = 2" \
+       "second thread started in inferior 2"
     gdb_test "inferior 1" "Switching to inferior 1 .*"
+    gdb_test "print \$_inferior_thread_count" " = 1" \
+       "still only one thread in inferior 1"
     gdb_continue_to_breakpoint "twice"
+    gdb_test "print \$_inferior_thread_count" " = 2" \
+       "second thread started in inferior 1"
 
     info_threads "" "1.1 1.2 2.1 2.2" \
        "info threads again"
 
        gdb_test "inferior 2" "Switching to inferior 2 .*"
        gdb_continue_to_breakpoint "once"
+       gdb_test "print \$_inferior_thread_count" " = 3" \
+           "third thread started in inferior 2"
 
        gdb_test "inferior 1" "Switching to inferior 1 .*"
+       gdb_test "print \$_inferior_thread_count" " = 2" \
+           "still only two threads in inferior 1"
        gdb_continue_to_breakpoint "twice"
+       gdb_test "print \$_inferior_thread_count" " = 3" \
+           "third thread started in inferior 1"
     }
 
     thr_apply_info_thr "1" \
 
   return thread_num_make_value_helper (gdbarch, 1);
 }
 
+/* Return a new value for the number of non-exited threads in the current
+   inferior.  If there are no threads in the current inferior return a
+   value of 0.  */
+
+static struct value *
+inferior_thread_count_make_value (struct gdbarch *gdbarch,
+                                 struct internalvar *var, void *ignore)
+{
+  int int_val = 0;
+
+  if (inferior_ptid != null_ptid)
+    int_val = current_inferior ()->non_exited_threads ().size ();
+
+  return value_from_longest (builtin_type (gdbarch)->builtin_int, int_val);
+}
+
 /* Commands with a prefix of `thread'.  */
 struct cmd_list_element *thread_cmd_list = NULL;
 
   NULL,
 };
 
+/* Implementation of `_inferior_thread_count` convenience variable.  */
+
+static const struct internalvar_funcs inferior_thread_count_funcs =
+{
+  inferior_thread_count_make_value,
+  NULL,
+};
+
 void _initialize_thread ();
 void
 _initialize_thread ()
 
   create_internalvar_type_lazy ("_thread", &thread_funcs, NULL);
   create_internalvar_type_lazy ("_gthread", >hread_funcs, NULL);
+  create_internalvar_type_lazy ("_inferior_thread_count",
+                               &inferior_thread_count_funcs, NULL);
 }
 
   IteratorType end () const
   { return m_end; }
 
+  /* The number of items in this iterator_range.  */
+  std::size_t size () const
+  { return std::distance (m_begin, m_end); }
+
 private:
   IteratorType m_begin, m_end;
 };