diff --git a/swift.c b/swift.c
index 4507ac055ce017669f5b4399b8ea2568253daeb0..8c54e51d1ec2741c660e87abe96bf7211b9ac32d 100644
--- a/swift.c
+++ b/swift.c
@@ -411,6 +411,8 @@ int main(int argc, char *argv[]) {
   }
 
   /* Deal with thread numbers */
+  if (nr_threads <= 0)
+    error("Invalid number of threads provided (%d), must be > 0.", nr_threads);
   if (nr_pool_threads == -1) nr_pool_threads = nr_threads;
 
   /* Write output parameter file */