0

This is my first application with multi thread concept.

Folder contains the more than 10 flat file, each flat file is 4 gb.

my script nearly took the 1 hrs for 1 flat file, so how to implement the parallel processing, and execute all files in multiple thread.

How i am reading file from folder ? just using while loop, call the SP inside while, flat file are the input for the SP.

What i want is : execute all flat file in one shot.

James Webster
  • 31,873
  • 11
  • 70
  • 114
DarshithCan
  • 23
  • 1
  • 5
  • 1
    This is already descibed here http://stackoverflow.com/questions/70855/how-can-one-use-multi-threading-in-php-applications – Greeso Nov 08 '12 at 14:36
  • If one file takes one hour to process, and you have ten of those, you're doing something seriously wrong and should reconsider your approach, as all the threads in the world won't help you, and PHP has only one. – adeneo Nov 08 '12 at 14:43
  • PHP does not support multithreading. – Adem Öztaş Nov 08 '12 at 14:44

2 Answers2

0

PHP does NOT support multi-threading. But you have control over processes.

Take a look at http://www.php.net/manual/en/ref.pcntl.php

Also you can use cUrl

Leri
  • 12,367
  • 7
  • 43
  • 60
0

Don't know if you have control over any front-end part for this app, but you could use AJAX :

  • Modify your script so it accepts a GET or POST parameter determining the flat file to handle (if needed)
  • Build a quick JS script (using jQuery or equivalent) and run as much asynchronous (default behaviour) AJAX calls as needed, triggered on a button click or anything.

You might have to toy around with AJAX timeouts (I guess PHP's and your web server's are fine since you were able to do that first hour-long execution).

neemzy
  • 1,899
  • 23
  • 25