Thread approach Q

I've been doing up the project which I had mentioned in another post here, but now I'm thinking maybe my approach to the whole thing was flawed. Here's what basically happens:

All threads need to be done using the POSIX or pthread.h and compile in Unix. G++.

The project needs to use 6 threads, 2 to open 2 files, 2 to calculate based on its data, and 2 to write to 2 other files.

-In the main function, the outfile is opened and wiped. Two threads are spawned and go to a getFile() function for opening.
-The getFile function does indeed open the files, gets the data, spawns 2 more threads and passes the number to another function, testPrime().
-The testPrime function uses mutex before calculating and performs the calculations. It then calls a writeFile() function, that accepts 5 arguments.
-The writeFile() function does not work at all with threads, so I have it threadless. I really have no idea what to do here.

Basically, the program works, but not in the desired way it's supposed to. Can anyone tell me if what I'm doing is a very bad idea or what...?

Here's my other post with some code snippets in it: http://www.dev-archive.com/forum/showthread.php?t=435605
[1267 byte] By [Sivakk] at [2007-11-20 11:15:58]
# 1 Re: Thread approach Q
Where is writeFile implemented ? Try debugging it. I dont think it's a posix API.
Krishnaa at 2007-11-9 1:25:21 >