Fix incorrect thread number used in 2D task with thread
diff --git a/src/fastpath.c b/src/fastpath.c
index 9ad58bf..64485e7 100644
--- a/src/fastpath.c
+++ b/src/fastpath.c
@@ -247,8 +247,9 @@
 	size_t i = index_i_j.quotient;
 	size_t j = index_i_j.remainder;
 
+	const size_t thread_number = thread->thread_number;
 	while (pthreadpool_decrement_fetch_relaxed_size_t(&thread->range_length) < range_threshold) {
-		task(argument, 0, i, j);
+		task(argument, thread_number, i, j);
 		if (++j == range_j.value) {
 			j = 0;
 			i += 1;
@@ -256,7 +257,6 @@
 	}
 
 	/* There still may be other threads with work */
-	const size_t thread_number = thread->thread_number;
 	for (size_t tid = modulo_decrement(thread_number, threads_count);
 		tid != thread_number;
 		tid = modulo_decrement(tid, threads_count))
diff --git a/src/portable-api.c b/src/portable-api.c
index 9a077bb..7cd1970 100644
--- a/src/portable-api.c
+++ b/src/portable-api.c
@@ -223,8 +223,9 @@
 	size_t i = index_i_j.quotient;
 	size_t j = index_i_j.remainder;
 
+	const size_t thread_number = thread->thread_number;
 	while (pthreadpool_try_decrement_relaxed_size_t(&thread->range_length)) {
-		task(argument, 0, i, j);
+		task(argument, thread_number, i, j);
 		if (++j == range_j.value) {
 			j = 0;
 			i += 1;
@@ -232,7 +233,6 @@
 	}
 
 	/* There still may be other threads with work */
-	const size_t thread_number = thread->thread_number;
 	const size_t threads_count = threadpool->threads_count.value;
 	for (size_t tid = modulo_decrement(thread_number, threads_count);
 		tid != thread_number;