Read with one thread, send datas to another thread
Im working with threads. In the following code, i read datas from txt and run it on my thread. I want to use another thread for writing the datas another txt file. How can i do it?
mythread.cpp
Code:
#include "mythread.h"
#include <QtCore>
#include <QDebug>
#include <QFile>
MyThread::MyThread()
{
}
void MyThread::run() //Reading file from txt with thread1
{
QFile file("C:/Users/ilknu/Documents/untitled1/deneme.txt");
{
while (!in.atEnd())
{
{
double num = entry.toDouble();
qDebug()<<num;
queue.enqueue(num);
} // for
} // while
} // if
file.close();
}
Re: Read with one thread, send datas to another thread
There is no reason to use threads for this. Open both files, read from one file, compute your sum, and write it to the second file. When the reading file is at the end, close both files.
Re: Read with one thread, send datas to another thread
Quote:
Originally Posted by
d_stranz
There is no reason to use threads for this.
We try to explain him this for a while - now he tries it in another forum :D
Re: Read with one thread, send datas to another thread
Maybe his toolbox is filled only with hammers, so every problem becomes a nail.