关于线程返回值的有关问题

关于线程返回值的问题
正在做一个数据处理的程序,出现这样一个问题。

最后会生成一个总的文件,文件里面是由若干数据组成,其中有两段数据是不相关的,所以我想用多线程来提高处理速度。但是呢,这两个数据要生成到一个文件内,且要求有先后顺序,请问多线程的返回值应该怎么处理,最好给个具体的代码实现,多谢各位。


ps: 楼下的大哥们可以拿这个举例子

我有两个方法
int func1 (int x,int y)
{ return x+y; }

int func2 (int x ,int y)
{return x*y;}

我希望用两个线程,分别执行两个方法,且把方法1的返回值存进 result  然后再把方法2 的返回值存进结果。

可行不?应该如何使用线程?谢谢
------解决方案--------------------
C# 4.0很简单:
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
    {
        static int Func1(int x, int y)
        {
            Thread.Sleep(8000);
            return x + y;
        }

        static int Func2(int x, int y)
        {
            Thread.Sleep(6000);
            return x * y;
        }

        static void Main(string[] args)
        {
            Stopwatch w = new Stopwatch();
            w.Start();
            Task<int> task1 = Task.Factory.StartNew(() => Func1(4, 10));
            Task<int> task2 = Task.Factory.StartNew(() => Func2(4, 10));
            Task.WaitAll(task1, task2);
            w.Stop();
            Console.WriteLine("{0} {1}\t time: {2}", task1.Result, task2.Result, w.ElapsedMilliseconds);
        }
    }
}


14 40    time: 8008
Press any key to continue . . .
------解决方案--------------------
关于线程返回值的有关问题
#include "stdafx.h"
#include <windows.h>
int tickets=100;
HANDLE hmutex;
DWORD WINAPI Function1( LPVOID lpParameter );
DWORD WINAPI Function2( LPVOID lpParameter );

int result=0;
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hthread1,hthread2;
hmutex=CreateMutex(NULL,TRUE,"Tickets");
hthread1=CreateThread(NULL,0,Function1,NULL,0,0);
hthread2=CreateThread(NULL,0,Function2,NULL,0,0);
CloseHandle(hthread1); 
CloseHandle(hthread2);    
printf("Main is running\r\n");
ReleaseMutex(hmutex);
Sleep(4000);
getchar();