Can you improve the speed of my CSV Reader and Writer?

hi all, i'm trying to develop a CSV Writer and Reader. i have done a good work to implement the special character and quoting it, it's also support multi line value but it's incredibly slow.
can someone help to make it faster?
here it's how to use the writer
char *stringhe_sorgenti[10] = {0};
out = OpenFile(nfile, VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_ASCII);
for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
stringhe_sorgenti[i] = (char*)calloc(200, sizeof(char));
sprintf(stringhe_sorgenti[0], "example1");
sprintf(stringhe_sorgenti[1], "example2");
scrivi_riga_csv(out, stringhe_sorgenti, sizeof(stringhe_sorgenti)/sizeof(char*), formato);
for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
free(stringhe_sorgenti[i]);
CloseFile(out);
here is the writer 
void scrivi_riga_csv(int file_handle, char *stringa_sorgente[], int numero_stringhe, int formato)
char delimitatore[2][2] = {{',', '\0'}, {';', '\0'}};
char stringa_destinazione[1024] = {0};
int index_destinazione = {0};
int index_start = {0};
int index_fine = {0};
int errore = {0};
int i = {0};
//int k = {0};
size_t lunghezza_stringa = {0};
for(i = 0; i < numero_stringhe; i++){
if(i != 0){
stringa_destinazione[index_destinazione++] = delimitatore[formato][0];
index_start = 0;
lunghezza_stringa = strlen(stringa_sorgente[i]);
// se la stringa sorgente
if( (FindPattern(stringa_sorgente[i], 0, lunghezza_stringa, delimitatore[formato], 0, 0) != -1) // contiene delimitatore
|| (FindPattern(stringa_sorgente[i], 0, lunghezza_stringa, "\"", 0, 0) != -1) // contiene parentesi
|| (FindPattern(stringa_sorgente[i], 0, lunghezza_stringa, "\n", 0, 0) != -1) // contiene a capo
// apro parentesi all'inizio
stringa_destinazione[index_destinazione++] = '"';
// metodo find pattern, piu' complesso ma piu' performante
do{ index_fine = FindPattern(stringa_sorgente[i], index_start, lunghezza_stringa - index_start, "\"", 0, 0);
if(index_fine != -1){
index_fine++;
// copio dall'inizio fino alle virgolette
CopyString (stringa_destinazione, index_destinazione, stringa_sorgente[i], index_start, index_fine - index_start);
index_destinazione += index_fine - index_start;
// ne aggiungo una dopo
stringa_destinazione[index_destinazione++] = '"';
// aggiorno la posizione di start e riparto con il while
index_start = index_fine;
}while(index_fine != -1);
CopyString (stringa_destinazione, index_destinazione, stringa_sorgente[i], index_start, lunghezza_stringa - index_start);
index_destinazione += strlen(stringa_sorgente[i]) - index_start;
// alla fine della riga chiudo la parentesi
stringa_destinazione[index_destinazione++] = '"';
else{
// altrimenti la copio semplicemente e shifto l'indice della stringa di destinazione
CopyString (stringa_destinazione, index_destinazione, stringa_sorgente[i], 0, lunghezza_stringa);
index_destinazione += strlen(stringa_sorgente[i]);
memset(stringa_sorgente[i], 0, strlen(stringa_sorgente[i]));
errore = WriteLine (file_handle, stringa_destinazione, strlen(stringa_destinazione));
if(errore == -1){
errore = GetFmtIOError();
MessagePopup("WriteLine -> WriteLine", GetFmtIOErrorString(errore));
return;
 here how to read the file
char *stringhe_sorgenti[10] = {0};
for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
stringhe_sorgenti[i] = (char*)calloc(200, sizeof(char));
out = OpenFile(nomearchivio, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_BINARY);
leggi_riga_csv(out, stringhe_sorgenti, sizeof(stringhe_sorgenti)/sizeof(char*), formato);
strcpy(intestazione.data, stringhe_sorgenti[1]);
for(i = 0; i < sizeof(stringhe_sorgenti)/sizeof(char*); i++){
free(stringhe_sorgenti[i]);
CloseFile(out);
 and here the reader
void leggi_riga_csv(int file_handle, char *stringa_destinazione[], int numero_stringhe, int formato)
char delimitatore[2][2] = {{',', '\0'},
{';', '\0'}};
char stringa_sorgente[1024] = {0};
int stringa_in_corso = {0};
int index_inizio_valore = {0};
int index_doublequote = {0};
int offset_stringa_destinazione = {0};
size_t lunghezza_stringa = {0};
int inquote = {0};
int errore = {0};
int i = {0};
for(i = 0; i < numero_stringhe; i++){
lunghezza_stringa = strlen(stringa_destinazione[i]);
memset(stringa_destinazione[i], 0, lunghezza_stringa);
do{ memset(&stringa_sorgente, 0, sizeof(stringa_sorgente));
errore = ReadLine(file_handle, stringa_sorgente, sizeof(stringa_sorgente) - 1);
// If ReadLine reads no bytes because it has already reached the end of the file, it returns –2.
// If an I/O error occurs, possibly because of a bad file handle, ReadLine returns –1.
// You can use GetFmtIOError to get more information about the type of error that occurred.
// A value of 0 indicates that ReadLine read an empty line.
if(errore == -1){
errore = GetFmtIOError();
MessagePopup("leggi_riga_csv -> ReadLine", GetFmtIOErrorString(errore));
return;
else if(errore == -2){
errore = GetFmtIOError();
MessagePopup("leggi_riga_csv -> ReadLine", "already reached the end of the file");
return;
else{
lunghezza_stringa = errore;
index_inizio_valore = 0;
// metodo find pattern, piu' complesso ma piu' performante
for(i = 0; i <= lunghezza_stringa; i++){
// se come primo carattere ho una " allora e' una stringa speciale
if(inquote == 0){
if(stringa_sorgente[i] == '\"'){
inquote = 1;
index_inizio_valore = ++i;
else{
// altrimenti cerco il delimitatore senza il ciclo for
i = FindPattern(stringa_sorgente, i, lunghezza_stringa - index_inizio_valore, delimitatore[formato], 0, 0);
if(i == -1){
// se non lo trovo ho finito la riga
i = lunghezza_stringa;
if(stringa_sorgente[i - 1] == '\r'){
i--;
if(stringa_in_corso < numero_stringhe){
CopyString (stringa_destinazione[stringa_in_corso], 0, stringa_sorgente, index_inizio_valore, i - index_inizio_valore);
offset_stringa_destinazione = 0;
stringa_in_corso++;
if(stringa_sorgente[i] == '\r'){
i++;
index_inizio_valore = i + 1;
if(inquote == 1){
// se sono nelle parentesi cerco le virgolette
i = 1 + FindPattern(stringa_sorgente, i, lunghezza_stringa - index_inizio_valore, "\"", 0, 0);
if(i == 0){
if(stringa_sorgente[lunghezza_stringa - 1] == '\r'){
lunghezza_stringa--;
// se non le trovo ho finito la riga, esco dal ciclo for
break;
// se incontro una doppia parentesi salto avanti
else if(stringa_sorgente[i] == '\"'){
continue;
// !!!! fondamentale non cambiare l'ordine di questi else if !!!!!
// se incontro una parentesi seguita dal delimitatore
// o se incontro una parentesi seguita dal terminatore
// \r = CR = 0x0D = 13
// \n = LF = 0x0A = 10
// a capo = CR + LF
else if( (stringa_sorgente[i] == delimitatore[formato][0])
|| (stringa_sorgente[i] == '\r')
|| (stringa_sorgente[i] == '\0')
// salvo il valore
inquote = 0;
if(stringa_in_corso < numero_stringhe){
CopyString (stringa_destinazione[stringa_in_corso], offset_stringa_destinazione, stringa_sorgente, index_inizio_valore, i - 1 - index_inizio_valore);
offset_stringa_destinazione = 0;
stringa_in_corso++;
if(stringa_sorgente[i] == '\r'){
i++;
index_inizio_valore = i;
// se sono andato a capo scrivo fino a dove sono e poi procedo con la nuova riga
if(inquote){
if(stringa_in_corso < numero_stringhe){
CopyString (stringa_destinazione[stringa_in_corso], offset_stringa_destinazione, stringa_sorgente, index_inizio_valore, lunghezza_stringa - index_inizio_valore);
strcat(stringa_destinazione[stringa_in_corso], "\n");
offset_stringa_destinazione += lunghezza_stringa - index_inizio_valore;
offset_stringa_destinazione++;
}while(inquote == 1);
// elimino le doppie parentesi
for(i = 0; i < numero_stringhe; i++){
index_doublequote = 0;
do{ lunghezza_stringa = strlen(stringa_destinazione[i]);
index_doublequote = FindPattern(stringa_destinazione[i], index_doublequote, lunghezza_stringa - index_doublequote, "\"\"", 0, 0); // contiene doppia parentesi
if(index_doublequote != -1){
index_doublequote++;
memmove (stringa_destinazione[i] + index_doublequote, stringa_destinazione[i] + index_doublequote + 1, lunghezza_stringa - index_doublequote);
}while(index_doublequote != -1);
return;

the format is CSV, i try to explain better what i'm doing.
our client asked to save acquisition data with header description in an excel readable format, i've decided to use .CSV and not .TDM because it's a simple txt file and we never used .TMD but i will propose to use it.
after some research on the internet i've found nothing to handle .CSV in CVI except from this csv_parse but i've found it difficult to be maintained so i've write it by my own hand.
i've written two example of how to use my function to read or write and i've copyed my function used to read and write.
in the write function i check with FindPattern if the string to be write contain some special character, if i find this i have to quote the string to respect the standard RFC4180 and if i find a quote i have to double it. aftere i've done this check i write the line in the file.
in the read function, that is more complicated, i:
check if the first character is a quote.
if it's not i copy the string until the delimitier or until the end of the line.
if it is i have a string with special character inside so:
i find the first quote in the string. when i've found i check if it's follwed by another quote. this means that in the starting message i was writing a single quote.
if it's not followed by another quote but it's followed by a delimiter or a carriage return i've finished the special line.
if i don't find it it means that the special quote have a carriage return inside and i have to check the next line. before checking the next line i save this in my string.
after this loop i check in every string if i have a double quote and i delete one.
the main problem is in the speed of this, i'm acquiring data at 1000 S/s with 8 active channel for 60 second so i have 480000 data to be stored, divided in 60.000 row and 8 column. to read a file like that my pc stay "locked" for 15 second or more.
i've tried to use the arraytofile function and it's extremly fast and i can also put header because the function can start from the last position in the file but the filetoarray function start from the beginning and i cannot read the header correctly. also if i'm using the european CSV with semicolon as delimiter with arraytofile i cannot select the semicolon but only the coma

Similar Messages

  • How can i improve the speed of my mac?

    my mac has 667 MHz, how can i improve the speed?

    Sorry if that sounded not very helpful, but basically it comes down to that. Not much can improve the performance of machine of that vintage, to stand up to a current model, unless you spend almost as much on upgrades (some of which to consider are listed below).
    Some thought should be given to the budget (money and time and effort) one is willing to spend. The G4 Digital Audio is possibly a good candidate for upgrading for someone who is interested in do-it-yourself computer stuff and bargain hunting for parts. It can even be a fun hobby. But even max-ing out all possible upgrades will still be lacking in performance compared to the current Mac models, I don't actually have any specific benchmarks, just my gut feel. And you may spend a good portion of the cost of a new machine on all those parts for the old machine.
    Is this the 667MHz machine (G4 Digital Audio) in question?
    http://www.lowendmac.com/ppc/digital-audio-power-mac-g4.html
    http://eshop.macsales.com/Descriptions/specs/Framework.cfm?page=g4da.html&title= Power%20Macintosh%20G4%20Digital%20Audio
    or is it some other model?
    Here are some CPU upgrades, for example:
    http://eshop.macsales.com/MyOWC/Upgrades.cfm?sort=pop&model=162&type=Processor&T I=2420&shoupgrds=Show+Upgrades
    you can even get a small rebate for your original CPU
    http://eshop.macsales.com/Service/rebate-program/
    Any of those CPUs should double your processing speed, but you may also need more RAM...or the CPU will just be waiting for data to be read from the virtual memory on the hard drive.
    http://eshop.macsales.com/item/Other%20World%20Computing/133SD512328/
    you could max it out with a whopping 1.5 GB, with 3 of these.
    and you may need a better video card...
    http://eshop.macsales.com/MyOWC/Upgrades.cfm?sort=pop&model=162&type=Video&TI=29 34&shoupgrds=Show+Upgrades
    To add larger and faster hard drives than the original Ultra ATA/66 can handle you would need a PCI ATA133 or PCI SATA card...
    http://eshop.macsales.com/item/ACARD/AEC6280MOB/
    http://eshop.macsales.com/item/Sonnet%20Technology/TSATA/
    And if you need to install OS X from a DVD, and want to burn your own DVD, you may need a new optical drive, if one hasn't been installed already, to replace the CD-RW:
    http://eshop.macsales.com/MyOWC/Upgrades.cfm?Model=162&Type=InternalOpticalDrives&sort=pop
    Also, check out the Power Macintosh G4 forums if you have any questions about that particular model, (if I guessed correctly)
    http://discussions.apple.com/category.jspa?categoryID=113
    Even while I am trying to build a case to convince someone not to waste their money on this project, I am thinking to myself, where can I pick up one of these G4 towers to take on this project myself. Maybe a Quicksilver, no a FW400 MDD dual-boot for sure, I still have some OS 9 software. I did about all I can with my G3 Desktop, and spent more than my MacBook cost.

  • HT1338 how can I improve the speed of my Macbook?  It's become incredibly slow...

    how can I improve the speed of my Macbook?  It's become incredibly slow...

    Hi,
    Troubleshooting Steps are... Restart...  Reset...  Restore from Backup...  Restore as New...
    Try a Reset of the Phone... You will Not Lose Any Data...
    Turn the Phone Off...
    Press and Hold the Sleep/Wake Button and the Home Button at the Same Time...
    The Apple logo will Appear and then Disappear...
    Usually takes about 10 - 15 Seconds...
    Turn the Phone On...
    If that does not help... See Here:
    http://support.apple.com/kb/HT1414
    iPhone User Guide
    http://manuals.info.apple.com/en_US/iphone_user_guide.pdf
    iPhone Syncing
    http://www.apple.com/support/iphone/syncing/

  • Can you connect the Lightning to 30-pin adapter and Lightning to 30-pin Adapter (0.2 m) to iPod nano (7th generation) with third-party accessories?

    Can you connect the Lightning to 30-pin adapter and Lightning to 30-pin Adapter (0.2 m) to iPod nano (7th generation) with third-party accessories?

    Lightning to 30-pin adapter and Lightning to 30-pin adapter (0.2m) do not work if connected together by other third-party accessories.

  • Can you take the SIM card from an IPad and transfer it to a NEW Ipad (not yet purchased) without any problems? Are there any complicated steps involved? Thanks.

    Can you take the SIM card from an IPad and transfer it to a NEW Ipad (not yet purchased) without any problems? Are there any complicated steps involved? This is for my boss.
    Please let me know. Thanks in advance.

    Simple answer is YES.
    The only caviat is for instance in the UK some iPads are locked to a specific network provider and therefore if the new iPad is locked then it will only work on the specific network it is locked to.

  • I have a new ipad with retina display and the orientation change from portrait to landscape is extremely slow? How can I improve the speed?

    Any ideas on how to improve the speed ?

    Hi rodtheprod,
    I apologize, I'm a bit unclear on the issue you are describing. If a movie from the iTunes Store supports multiple languages, they can usually be changed as outlined in the following article:
    iTunes: Language settings for video
    http://support.apple.com/kb/HT5562
    If this is not possible and no changes have been made to the country settings for the iTunes Store, you may want to try redownloading the movie (if it is still available):
    Download past purchases
    http://support.apple.com/kb/HT2519
    Regards,
    - Brenden

  • In ical, how can you tell the difference between a meeting invite and email?

    When you send a meeting invite in ical, does the recipient receive a different icon in their inbox to differentiate from an email?

    For service stock you can't tell the difference between a new iPad and a refurbished one. Both will come in a plain brown box with the same pattern in model numbers. If you mean between a refurbished one and one new at retail, then other than the obvious difference in packaging, I've read that the model number on refurbished units starts with the letter "F", though I've not confirmed that.
    Regards.

  • How can you tell the differance between an iphone charger and an ipad charger?

    how can you tell the differance between an iphone and ipad charger

    http://store.apple.com/us/product/MC359LL/A/apple-ipad-10w-usb-power-adapter?fno de=3c
    http://store.apple.com/us/product/MD810LL/A/apple-5w-usb-power-adapter?fnode=48

  • Urgent: Please help. how to solve the time delay during buffer read and write using vc++

    I need to continuously acquire data from daqmx card, write into a file and at the same time corelate (in terms of time) the data with signals from other instruments. The current problem is that there is time delay during read and write data into buffer,thus causing misalignment of the data from multiple instruments. Is there a way to solve  the delay? or Is there a way to mark the time of the data acquisition in the buffer?  If I know the starting time (e.g. 0) of data acquisition and sampling rate (e.g. 1kHz), can I simply add 1ms to each data sample in the buffer? The current code is shown below.
    void DataCollectionWin::ConnectDAQ()
    DAQmxErrChk(DAQmxCreateTask ("", &taskHandle));
        DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0,Dev1/ai1,Dev1/ai2,Dev1/ai3,Dev1/ai4,Dev1/ai5,Dev1/ai16,Dev1/ai17,Dev1/ai18,Dev1/ai19,Dev1/ai20,Dev1/ai21,Dev1/ai6,Dev1/ai7,Dev1/ai22","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
      DAQmxErrChk(DAQmxCfgSampClkTiming(taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,60000));
      DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,50,0,EveryNCallback,NULL));// Every 50 samples the EveryNSamplesEvent will be trigured, to reduce time delay.
      DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));
      DAQmxErrChk (DAQmxStartTask(taskHandle));
    int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
     DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,50,10.0,DAQmx_Val_GroupByScanNumber,data,50*15,&read,NULL));
       //memcpy(l_data,data,6000);
      SetEvent(hEvent);
    l_usstatus_e[0]=g_usstatus[0];// signals from other instruments that need to be corelated with the data from daq cards.
     l_optstatus_e[0]=g_optstatus[0];
     if( read>0 ) // write data into file
       //indicator=1;
     for (i=0;i<read;i++)
     {  //fprintf(datafile,"%d\t",i);
      fprintf(datafile,"%c\t",l_usstatus_s[0]);
      fprintf(datafile,"%c\t",l_usstatus_e[0]);
            fprintf(datafile,"%c\t",l_optstatus_s[0]);
      fprintf(datafile,"%c\t",l_optstatus_e[0]);
              fprintf(datafile,"%.2f\t",data[15*i]);
     //   sprintf( pszTemp, "%f", data[6*i]);
     // pListCtrl->SetItemText(0, 2, pszTemp);
        //pWnd->m_trackinglist.SetItemText(0, 2, pszTemp);
         fprintf(datafile,"%.2f\t",data[15*i+1]);
         fprintf(datafile,"%.2f\t",data[15*i+2]);

    Hello kgy,
    It is a bit of a judgment call. You should just choose the board that you think has the most to do with your issue. For example, this issue was much more focused on setting up your data acquisition task than the Measurement Studio environment/tools, so the MultifunctionDAQ board would have been the best place for it. As for moving your post to another board, I do not believe that is possible.
    Regards,
    Dan King

  • Using the Borland Database Engine to read AND write SHARED Paradox Database Tables

    I need to read and write Paradox database tables with a C# AT THE SAME TIME AS people using the Paradox tables with legacy Paradox programs interactively.
    I think the only way to do that reliably without corrupting the tables is to use the BDE Borland Database Engine.
    Does anyone know how to do that? I found this c++ program... But I don't know how to integrate this into c#
    http://www.codeproject.com/KB/database/bdedatabase.aspx
    Is there another way to do this? Again, most important, I don't want to corrupt the paradox database.
    I can read the paradox records all day long, that is no problem, it is updating at the same time as the legacy program users..
    I also know that the whole thing needs to be updated, but that can not be done overnight.
    Thanks in advance
    Dave

    Being pretty new to programming, I am trying just to read info from Paradox tables with C#. Info is actively being updated from another program at the same time. The program I am trying to write only needs to read data. The other program does use the BDE,
    so it is already present running on the computer.
    I've been looking at code but just haven't found quite the right combination.
    Thanks. Any help is greatly appreciated.

  • Is there a way to use the FF vi's to read and write complex data types; specifically, clusters?

    I'm trying to interface with a Fieldbus device through LabVIEW.  I need to be able to read and write a variable that consists of a cluster of two unsigned int 32's.  The FF vi's provided with FF Communications Manager 3.2 do not support clusters.  I have tried to use a code interface node to write my own, but the CIN's I was using before to do this function do not give me a device list anymore (they were originally written on Communications Manager 2.3.5).  I have recompiled the .lsb, as well as trying to use the older versions of the header and library files.  Is there another workaround I can use?

    Hello Bryan,
    The BrowseDeviceList VI was released within NI-FBUS 3.2. For NI-FBUS Configurator 3.1, please unzip the attached file and copy the "addon" and "Ff" folders into "\vi.lib" directory. LabVIEW 7.1 or above version is required for using these addons.
    And for your information, there is a free upgrade (version 3.1.1) for NI-FBUS Configurator 3.1 users. Here is the link to the upgrade kit.
    http://digital.ni.com/softlib.nsf/websearch/00A1614EC291219586256F390020671B?opendocument&node=132070_US
    Hope it helps!
    Regards,
    --Josiane
    Attachments:
    locate_fflv_in_labview82.jpg ‏214 KB
    vi.lib.zip ‏391 KB
    locate_fflv_in_labview71.jpg ‏193 KB

  • Can't stop synchronized threads with I/O read and write

    I have two synchronized threads which doing read and write from and into a file.
    One thread called "reader" which does reading, encoding, etc from a source file and puts its output in a pre-defined variable. Another called "writer" which puts the reader's output into a file ( not the source file ). Both thread will notify each other when they've finished each of their part. It's similiar to CubyHole example of Java Tutorial example from Sun.
    But somehow it seems like the threads keep spawning and won't die. Even if the source file has been all read and the data has been fully written, calling interrupt(), return, etc has no effect. The threads will keep running untill System.exit() called.
    Is it because the threads were blocked for I/O operation and the only way to kill them is to close the I/O ?
    To be honest, it's not only stop the threads that I want to, I also want to somehow pause the threads manually in the middle of the process.
    Is it possible ?
    Cheers.!!!

    The example code for the problem using 4 classes called :
    - libReadWrite ( class holding methods for aplication operations )
    - reader ( thread class responsible for reading data )
    - writer ( thread class responsible for writing data )
    - myGUI ( user interface class )
    All of them written in different file.
    // libReadWrite
    pubic class libReadWrite {
    private boolean dataReady;
    private String theData;
    //read data
    public synchronized void read(String inputFile) {
    while (dataReady == true) {
    try {
    wait();
    } catch (InterruptedException ex) {}
    RandomAccessFile raf = new RandomAccessFile(inputFile, "r"); // I'm using raf here because there are a lot of seek operations
    theData = "whatever"; // final data after several unlist processes
    dataReady = true;
    notifyAll();
    public synchronized void write(String outputFile) {
    while (dataReady == false) {
    try {
    wait();
    } catch (InterruptedException ex) {}
    DataOutputStream output = new DataOutputStream(new FileOutputStream(outputFile, true));
    output.writeBytes(theData);
    dataReady = false;
    notifyAll();
    //Reader
    public class reader extends Thread {
    private libReadWrite myLib;
    private String inputFile;
    public reader (libReadWrite myLib, String inputFile) {
    this.myLib = myLib;
    this.inputFile = inputFile;
    public void run() {
    while (!isInterrupted()) {
    myLib.read(inputFile); <-- this code running within a loop
    return;
    public class writer extends Thread {
    private libReadWrite myLib;
    private String outputFile;
    public writer (libReadWrite myLib, String outputFile) {
    this.myLib = myLib;
    this.outputFile = outputFile;
    public void run() {
    while (!isInterrupted()) {
    myLib.write(outputFile); <-- this code running within a loop
    try {
    sleep(int)(Math.random() + 100);
    } catch (InterruptedException ex) {}
    return;
    //myGUI
    public class myGUI extends JFrame {
    private libReadWrite lib;
    private reader readerRunner;
    private writer writerRunner;
    //Those private variables initialized when the JFrame open (windowOpened)
    libReadWrite lib = new libReadWrite();
    reader readerRunner = new reader("inputfile.txt");
    writer writerRunner = new writer("outputfile.txt");
    //A lot of gui stuffs here but the thing is below. The code is executed from a button actionPerformed
    if (button.getText().equals("Run me")) {
    readerRunner.start();
    writerRunner.start();
    button.setText("Stop me");
    } else {
    readerRunner.interrupt();
    writerRunner.interrupt();
    }

  • How can I improve the speed of my G4 Powerbook.

    My G-4 Powerbook, bought 3 years ago, is sooooooooooo slow. I am so tired of seeing that colorful spinning thing always spinning. I'm not yet ready for a new computer. . My system specs are 1.67ghz 512 RAM 80gb HD, and I'm running current version of Tiger. Would upgrading to 1G of RAM help? I was told by Apple's telephone tech support that I have 2 cards of 256 ram each. If I were to upgrade 1 or 2 of them to a 512 card I would see a big difference in speed. Anybody have any experience with this, or any comments. Would appreciate. Lyn in Manhattan

    Welcome to the Apple discussions.
    It's not unusual to see Powerbooks around 3 or so years old slowing down - I agree it gets old, fast. First thing to do is clean up the hard disk, which can accumulate 'stuff' over time. If you don't have it already, download OnyX for Tiger from http://www.titanium.free.fr/pgs2/english/download.html . A number of people have used this to fine tune and improve the performance of their system.
    In OnyX, use the maintenance tab, do permissions and scripts.
    Use the cleaning tab: Internet clear caches, browser history, recent searches. Caches, if you clear your kernel/system cache, your system may be a little slower to reboot while it rebuilds the cache - I clear these before an operating system upgrade. Log, delete log files, crash reporter logs, and archived logs. Trash, delete. Misc, delete temporary and obsolete items.
    Another resource to look at is Dr Smokes performance FAQ at http://www.thexlab.com/faqs/performance.html
    Also, make sure you have at least 10% of your disk free, for systems usage. Performance can decline rapidly if there's not enough disk space.
    An easy way to see if more memory would help is to bring up your activity monitor (on your hard drive in applications/utilities). Look at the system memory tab, specifically at page ins and page outs. If outs are more than 10%-20% of page ins, you can benefit from more memory. A page out is when the system writes memory to the hard drive, to make room for something else. Do that too much, and you impact performance. Recommend Crucial, Kingston (not their value ram, however), or Samsung as three brands that work reliably in our Powerbooks. Crucial's site is http://www.crucial.com , Kingston is at http://www.kingston.com , and Samsung is available through distibutors - I use OWC at http://www.macsales.com . If you decide to upgrade, I'd pull one of the 256MB cards and put a 1GB card in it's place. Going from 512MB to 768MB isn't that big a change.
    This should get you rolling in the right direction - please post back with any questions.

  • How can I improve the speed of my QuickVPN connection?

    I have finally got my "Quick"VPN connection working with my small business network. In the past, I used a PPTP VPN via Windows to connect to the network, but was limited to one person on at a time. Now I have a QuickVPN we can have up to 10 people connected, but the speed is considerably slower. I haven't done any hard core testing. Before I spend even more time on this, I wanted to see if there were any good ideas out there.
    Do you have any?
    Thanks!

    I have finally got my "Quick"VPN connection working with my small business network. In the past, I used a PPTP VPN via Windows to connect to the network, but was limited to one person on at a time. Now I have a QuickVPN we can have up to 10 people connected, but the speed is considerably slower. I haven't done any hard core testing. Before I spend even more time on this, I wanted to see if there were any good ideas out there.
    Do you have any?
    Thanks!

  • Can you adjust the speed of a clip in iMovie '08?

    I know you could adjust make things go in slow-mo, etc. in the older version of iMovie and it looks like iMovie '09 lets you do so. But I can't figure out how to do it in iMovie '08? Any hints?

    This feature is not built into iMovie 08. However, you can take a clip and use a third party app like JES Deinterlacer to change the speed. Then reimport the new clip into iMovie.

Maybe you are looking for