diff --git a/pocketfft_hdronly.h b/pocketfft_hdronly.h
index a90bd400fead85a91ae120da52ec4e1e4e3b7f7f..ea282b622a0d68b4ab2f88d60fe543f03821a8c8 100644
--- a/pocketfft_hdronly.h
+++ b/pocketfft_hdronly.h
@@ -721,6 +721,7 @@ namespace threading {
 
 constexpr size_t thread_id = 0;
 constexpr size_t num_threads = 1;
+constexpr size_t max_threads = 1;
 
 template <typename Func>
 void thread_map(size_t /* nthreads */, Func f)
@@ -730,6 +731,7 @@ void thread_map(size_t /* nthreads */, Func f)
 
 thread_local size_t thread_id = 0;
 thread_local size_t num_threads = 1;
+static const size_t max_threads = max(1u, thread::hardware_concurrency());
 
 class latch
   {
@@ -836,7 +838,7 @@ class thread_pool
       threads_(nthreads)
       { create_threads(); }
 
-    thread_pool(): thread_pool(thread::hardware_concurrency()) {}
+    thread_pool(): thread_pool(max_threads) {}
 
     ~thread_pool() { shutdown(); }
 
@@ -883,7 +885,7 @@ template <typename Func>
 void thread_map(size_t nthreads, Func f)
   {
   if (nthreads == 0)
-    nthreads = thread::hardware_concurrency();
+    nthreads = max_threads;
 
   if (nthreads == 1)
     { f(); return; }