# C.61 ParallelTask
Executes nested tasks in parallel.
Parallel tasks have a number of uses in a Phing build file including:
- Taking advantage of available processing resources to execute external programs simultaneously.
- Testing servers, where the server can be run in one thread and the test harness is run in another thread.
Any valid Phing task may be embedded within a parallel task, including other parallel tasks.
While the tasks within the parallel task are being run, the main thread will be blocked waiting for all the child threads to complete. If one of the tasks within the `parallel` task fails, the remaining tasks will continue to run until all tasks have completed. In this situation, the parallel task will also fail.
The threadCount attribute can be used to place a maximum number of available threads for the execution. When not present the value is based on the number of processors present. When present then the maximum number of concurrently executing tasks will not exceed the number of threads specified. Furthermore, each task will be started in the order they are given. But no guarantee is made as to the speed of execution or the order of completion of the tasks, only that each will be started before the next.
### Warning
This task is highly experimental, and will only work on \*nix machines that have the PHP `pcntl` extension installed.
Table C.72:聽Attributes
NameTypeDescriptionDefaultRequired`threadCount``Integer`Maximum number of threads / processes to use.n/aNo
C.61.1 Example
```
<parallel threadCount="4">
<echo>Job 1</echo>
<echo>Job 2</echo>
<echo>Job 3</echo>
<echo>Job 4</echo>
</parallel>
```
- Phing User Guide
- Preface
- 1. About this book
- 1.1. Authors
- 1.2. Copyright
- 1.3. License
- 1.4. DocBook
- 1.4.1. Building the documentation
- 1.4.2. Template for new tasks
- 1.4.3. Customization of the look & feel of the rendered outputs
- 1.4.4. DocBook v5 elements used in the manual and their meaning
- 2. Introduction
- 2.1. What Phing Is
- 2.2. Phing & Binarycloud: History
- 2.3. How Phing Works
- 2.4. Cool, so how can I help?
- 2.4.1. Participating in the development
- 3. Setting-up Phing
- 3.1. System Requirements
- 3.1.1. Operating Systems
- 3.1.2. Software Dependencies
- 3.2. Obtaining Phing
- 3.2.1. Distribution Files
- 3.2.2. Getting the latest source from Phing Git repository
- 3.3. Composer Install
- 3.4. Phar package
- 3.5. Running Phing
- 3.5.1. Command Line
- 3.5.2. Supported command line arguments
- 4. Getting started
- 4.1. XML And Phing
- 4.2. Writing A Simple Buildfile
- 4.2.1. Project Element
- 4.2.2. Target Element
- 4.2.2.1. Target attributes
- 4.2.3. Task Elements
- 4.2.4. Property Element
- 4.2.4.1. Built-in Properties
- 4.3. More Complex Buildfile
- 4.3.1. Handling source dependencies
- 4.4. Relax NG Grammar
- 5. Project components
- 5.1. Projects
- 5.2. Version
- 5.3. Project Components in General
- 5.4. Targets
- 5.5. Tasks
- 5.6. Types
- 5.6.1. Basics
- 5.6.2. Referencing Types
- 5.7. Basic Types
- 5.7.1. FileSet
- 5.7.2. FileList
- 5.7.3. FilterChains and Filters
- 5.7.4. File Mappers
- 5.8. Conditions
- 5.8.1. not
- 5.8.2. and
- 5.8.3. or
- 5.8.4. xor
- 5.8.5. os
- 5.8.6. equals
- 5.8.7. versioncompare
- 5.8.8. http
- 5.8.9. socket
- 5.8.10. hasfreespace
- 5.8.11. isset
- 5.8.12. contains
- 5.8.13. istrue
- 5.8.14. isfalse
- 5.8.15. ispropertytrue
- 5.8.16. ispropertyfalse
- 5.8.17. referenceexists
- 5.8.18. available
- 5.8.19. filesmatch
- 5.8.20. isfileselected
- 5.8.21. isfailure
- 5.8.22. matches
- 6. Extending Phing
- 6.1. Extension Possibilities
- 6.1.1. Tasks
- 6.1.2. Types
- 6.1.3. Mappers
- 6.2. Source Layout
- 6.2.1. Files And Directories
- 6.2.2. File Naming Conventions
- 6.2.3. Coding Standards
- 6.3. System Initialization
- 6.3.1. Wrapper Scripts
- 6.3.2. The Main Application (phing.php)
- 6.3.3. The Phing Class
- 6.4. System Services
- 6.4.1. The Exception system
- 6.5. Build Lifecycle
- 6.5.1. How Phing Parses Buildfiles
- 6.6. Writing Tasks
- 6.6.1. Creating A Task
- 6.6.2. Using the Task
- 6.6.3. Source Discussion
- 6.6.4. Task Structure
- 6.6.5. Includes
- 6.6.6. Class Declaration
- 6.6.7. Class Properties
- 6.6.8. The Constructor
- 6.6.9. Setter Methods
- 6.6.10. Creator Methods
- 6.6.11. init() Method
- 6.6.12. main() Method
- 6.6.13. Arbitrary Methods
- 6.7. Writing Types
- 6.7.1. Creating a DataType
- 6.7.2. Using the DataType
- 6.7.3. Source Discussion
- 6.7.3.1. Getters & Setters
- 6.7.3.2. The getRef() Method
- 6.8. Writing Mappers
- 6.8.1. Creating a Mapper
- 6.8.2. Using the Mapper
- A. Fact Sheet
- A.1. Built-In Properties
- A.2. Command Line Arguments
- A.3. Distribution File Layout
- A.4. Program Exit Codes
- A.5. The LGPL License
- A.6. The GFDL License
- B. Core tasks
- B.1. AdhocTaskdefTask
- B.1.1. Examples
- B.2. AdhocTypedefTask
- B.2.1. Example
- B.3. AppendTask
- B.3.1. Examples
- B.3.2. Supported Nested Tags
- B.4. ApplyTask
- B.4.1. Examples
- B.4.2. Supported Nested Tags
- B.5. AttribTask
- B.5.1. Example
- B.5.2. Supported Nested Tags
- B.6. AvailableTask
- B.6.1. Examples
- B.7. Basename
- B.7.1. Examples
- B.8. ChmodTask
- B.8.1. Examples
- B.8.2. Supported Nested Tags
- B.9. ChownTask
- B.9.1. Examples
- B.9.2. Supported Nested Tags
- B.10. ConditionTask
- B.10.1. Examples
- B.10.2. Supported Nested Tags
- B.11. CopyTask
- B.11.1. Examples
- B.11.2. Supported Nested Tags
- B.12. DefaultExcludes
- B.12.1. Examples
- B.13. DeleteTask
- B.13.1. Examples
- B.13.2. Supported Nested Tags
- B.14. DependSet
- B.14.1. Examples
- B.14.2. Supported Nested Tags
- B.15. Diagnostics
- B.15.1. Example
- B.16. Dirname
- B.16.1. Example
- B.17. EchoTask
- B.17.1. Examples
- B.17.2. Supported Nested Tags
- B.18. EchoPropertiesTask
- B.18.1. Example
- B.19. ExecTask
- B.19.1. Examples
- B.19.2. Supported Nested Tags
- B.20. FailTask
- B.20.1. Examples
- B.20.2. Parameters specified as nested elements.
- B.21. ForeachTask
- B.21.1. Examples
- B.21.2. Supported Nested Tags
- B.22. IfTask
- B.22.1. Examples
- B.23. ImportTask
- B.23.1. Target Overriding
- B.23.2. Special Properties
- B.23.3. Resolving Files Against the Imported File
- B.23.4. Examples
- B.24. IncludePathTask
- B.24.1. Examples
- B.25. InputTask
- B.25.1. Examples
- B.26. LoadFileTask
- B.26.1. Examples
- B.26.2. Supported Nested Tags:
- B.27. MkdirTask
- B.27.1. Examples
- B.28. MoveTask
- B.28.1. Examples
- B.28.2. Attributes and Nested Elements
- B.29. PathConvert
- B.30. PhingTask
- B.30.1. Examples
- B.30.2. Supported Nested Tags
- B.30.3. Base directory of the new project
- B.31. PhingCallTask
- B.31.1. Examples
- B.31.2. Supported Nested Tags
- B.32. Phingversion
- B.32.1. Example
- B.33. PhpEvalTask
- B.33.1. Examples
- B.33.2. Supported Nested Tags
- B.34. PropertyTask
- B.34.1. Examples
- B.34.2. Supported Nested Tags:
- B.35. PropertyPromptTask
- B.35.1. Examples
- B.36. Record
- B.36.1. Example
- B.37. ReflexiveTask
- B.37.1. Examples
- B.37.2. Supported Nested Tags:
- B.38. ResolvePathTask
- B.38.1. Examples
- B.39. Retry
- B.39.1. Example
- B.40. RunTargetTask
- B.40.1. Example
- B.41. SleepTask
- B.41.1. Example
- B.42. SwitchTask
- B.42.1. Supported Nested Tags
- B.42.2. Examples
- B.43. TaskdefTask
- B.43.1. Examples
- B.43.2. Supported Nested Tags
- B.44. Tempfile Task
- B.44.1. Example
- B.45. TouchTask
- B.45.1. Examples
- B.45.2. Supported Nested Tags
- B.46. TruncateTask
- B.46.1. Examples
- B.47. TryCatchTask
- B.47.1. Examples
- B.48. TstampTask
- B.48.1. Examples
- B.48.2. Supported Nested Tags
- B.49. TypedefTask
- B.49.1. Examples
- B.49.2. Supported Nested Tags
- B.50. UpToDateTask
- B.50.1. Examples
- B.50.2. Supported Nested Tags
- B.51. WaitForTask
- B.51.1. Examples
- B.51.2. Supported Nested Tags
- B.52. XsltTask
- B.52.1. Examples
- B.52.2. Supported Nested Tags
- C. Optional tasks
- C.1. ApiGenTask
- C.1.1. Example
- C.2. AutoloaderTask
- C.2.1. Example
- C.3. ComposerTask
- C.3.1. Supported Nested Tags
- C.4. CoverageMergerTask
- C.4.1. Example
- C.4.2. Supported Nested Tags
- C.5. CoverageReportTask
- C.5.1. Example
- C.5.2. Supported Nested Tags
- C.6. CoverageSetupTask
- C.6.1. Example
- C.6.2. Supported Nested Tags
- C.7. CoverageThresholdTask
- C.7.1. Example
- C.7.2. Supported Nested Tags
- C.8. DbDeployTask
- C.8.1. Example
- C.9. ExportPropertiesTask
- C.9.1. Example
- C.10. FileHashTask
- C.10.1. Example
- C.11. FileSizeTask
- C.11.1. Example
- C.12. FileSyncTask
- C.12.1. Examples
- C.13. FtpDeployTask
- C.13.1. Example
- C.13.2. Supported Nested Tags
- C.14. GitArchiveTask
- C.14.1. Example
- C.15. GitBranchTask
- C.15.1. Example
- C.16. GitCheckoutTask
- C.16.1. Example
- C.17. GitCloneTask
- C.17.1. Example
- C.18. GitCommitTask
- C.18.1. Example
- C.18.2. Supported Nested Tags
- C.19. GitFetchTask
- C.19.1. Example
- C.20. GitGcTask
- C.20.1. Example
- C.21. GitInitTask
- C.21.1. Example
- C.22. GitLogTask
- C.22.1. Example
- C.23. GitMergeTask
- C.23.1. Example
- C.24. GitPullTask
- C.24.1. Example
- C.25. GitPushTask
- C.25.1. Example
- C.26. GitTagTask
- C.26.1. Example
- C.27. GitDescribeTask
- C.27.1. Example
- C.28. GrowlNotifyTask
- C.28.1. Examples
- C.29. HgAddTask
- C.29.1. Example
- C.29.2. Supported Nested Tags
- C.30. HgArchiveTask
- C.30.1. Example
- C.31. HgCloneTask
- C.31.1. Example
- C.32. HgCommitTask
- C.32.1. Example
- C.33. HgInitTask
- C.33.1. Example
- C.34. HgLogTask
- C.34.1. Example
- C.35. HgPullTask
- C.35.1. Example
- C.36. HgPushTask
- C.36.1. Example
- C.37. HgRevertTask
- C.37.1. Example
- C.38. HgTagTask
- C.38.1. Example
- C.39. HgUpdateTask
- C.39.1. Example
- C.40. HipchatTask
- C.40.1. Example
- C.41. HttpGetTask
- C.41.1. Example
- C.41.2. Supported Nested Tags
- C.41.3. Global configuration
- C.42. HttpRequestTask
- C.42.1. Example
- C.42.2. Supported Nested Tags
- C.42.3. Global configuration
- C.43. IniFileTask
- C.43.1. Supported Nested Tags
- C.43.2. Example
- C.44. IoncubeEncoderTask
- C.44.1. Example
- C.44.2. Supported Nested Tags
- C.45. IoncubeLicenseTask
- C.45.1. Example
- C.45.2. Supported Nested Tags
- C.46. JsHintTask
- C.46.1. Example
- C.46.2. Supported Nested Tags
- C.47. JslLintTask
- C.47.1. Example
- C.47.2. Supported Nested Tags
- C.48. JsMinTask
- C.48.1. Example
- C.48.2. Supported Nested Tags
- C.49. JsonValidateTask
- C.49.1. Example
- C.50. LiquibaseTask
- C.50.1. Example
- C.50.2. Supported Nested Tags
- C.51. LiquibaseChangeLogTask
- C.51.1. Example
- C.51.2. Supported Nested Tags
- C.52. LiquibaseDbDocTask
- C.52.1. Example
- C.52.2. Supported Nested Tags
- C.53. LiquibaseDiffTask
- C.53.1. Example
- C.53.2. Supported Nested Tags
- C.54. LiquibaseRollbackTask
- C.54.1. Example
- C.54.2. Supported Nested Tags
- C.55. LiquibaseTagTask
- C.55.1. Example
- C.55.2. Supported Nested Tags
- C.56. LiquibaseUpdateTask
- C.56.1. Example
- C.56.2. Supported Nested Tags
- C.57. MailTask
- C.57.1. Example
- C.57.2. Supported Nested Tags
- C.58. ManifestTask
- C.58.1. Supported Nested Tags
- C.59. NotifySendTask
- C.60. PackageAsPathTask
- C.60.1. Example
- C.61. ParallelTask
- C.61.1. Example
- C.62. PatchTask
- C.62.1. Example
- C.63. PathToFileSetTask
- C.63.1. Examples
- C.64. PDOSQLExecTask
- C.64.1. Example
- C.64.2. Supported Nested Tags
- C.65. PearPackageTask
- C.65.1. Example
- C.65.2. Supported Nested Tags
- C.66. PearPackage2Task
- C.66.1. Example
- C.66.2. Supported Nested Tags
- C.67. PharDataTask
- C.67.1. Example
- C.67.2. Supported Nested Tags
- C.68. PharPackageTask
- C.68.1. Example
- C.68.2. Supported Nested Tags
- C.69. PhkPackageTask
- C.69.1. Example
- C.69.2. Supported Nested Tags
- C.70. PhpCodeSnifferTask
- C.70.1. Examples
- C.70.2. Supported Nested Tags
- C.71. PHPCPDTask
- C.71.1. Examples
- C.71.2. Supported Nested Tags
- C.72. PHPLocTask
- C.72.1. Examples
- C.72.2. Supported Nested Tags
- C.73. PHPMDTask
- C.73.1. Example
- C.73.2. Supported Nested Tags
- C.74. PhpDependTask
- C.74.1. Example
- C.74.2. Supported Nested Tags
- C.75. PhpDocumentor2Task
- C.75.1. Example
- C.75.2. Supported Nested Tags
- C.76. PhpLintTask
- C.76.1. Example
- C.76.2. Supported Nested Tags
- C.77. PHPUnitTask
- C.77.1. Supported Nested Tags
- C.77.2. Example
- C.77.3. Supported Nested Tags
- C.78. PHPUnitReport
- C.78.1. Example
- C.79. PropertyCopy
- C.79.1. Example
- C.80. PropertyRegexTask
- C.80.1. Match expressions
- C.80.2. Replace
- C.80.3. Example
- C.81. ReplaceRegexpTask
- C.81.1. Supported Nested Tags
- 1. PropertySelector
- 1.1. Select expressions
- 1.2. Example
- C.82. rSTTask
- C.82.1. Features
- C.82.2. Examples
- C.82.3. Supported Nested Tags
- C.83. S3PutTask
- C.83.1. Example
- C.83.2. Supported Nested Tags
- C.84. S3GetTask
- C.84.1. Example
- C.85. SassTask
- C.85.1. Example
- C.85.2. Supported Nested Tags
- C.86. ScpTask
- C.86.1. Example
- C.86.2. Supported Nested Tags
- C.87. SmartyTask
- C.88. SonarTask
- C.88.1. Examples
- C.88.1.1. Minimal Example
- C.88.1.2. Full Example
- C.88.2. Supported Nested Tags
- C.89. SortList
- C.89.1. Example
- C.90. SshTask
- C.90.1. Example
- C.90.2. Supported Nested Tags
- C.91. SvnCheckoutTask
- C.91.1. Example
- C.92. SvnCommitTask
- C.92.1. Example
- C.93. SvnCopyTask
- C.93.1. Example
- C.94. SvnExportTask
- C.94.1. Example
- C.95. SvnInfoTask
- C.95.1. Example
- C.96. SvnLastRevisionTask
- C.96.1. Example
- C.97. SvnListTask
- C.97.1. Example
- C.98. SvnLogTask
- C.98.1. Example
- C.99. SvnUpdateTask
- C.99.1. Example
- C.100. SvnSwitchTask
- C.100.1. Example
- C.101. SvnProplistTask
- C.101.1. Example
- C.102. SvnPropgetTask
- C.102.1. Example
- C.103. SvnPropsetTask
- C.103.1. Example
- C.104. StopwatchTask
- C.104.1. Example
- C.105. SymfonyConsoleTask
- C.105.1. Examples
- C.105.2. Supported Nested Tags
- C.106. SymlinkTask
- C.106.1. Example
- C.106.2. Supported Nested Tags
- C.107. TarTask
- C.107.1. Example
- C.107.2. Supported Nested Tags
- C.108. ThrowTask
- C.108.1. Example
- C.109. UntarTask
- C.109.1. Example
- C.109.2. Supported Nested Tags
- C.110. UnzipTask
- C.110.1. Example
- C.110.2. Supported Nested Tags
- C.111. Variable
- C.111.1. Example
- C.112. VersionTask
- C.112.1. Example
- C.113. WikiPublishTask
- C.113.1. Example
- C.114. XmlLintTask
- C.114.1. Examples
- C.114.2. Supported Nested Tags
- C.115. XmlPropertyTask
- C.115.1. Example
- C.116. ZendCodeAnalyzerTask
- C.116.1. Example
- C.116.2. Supported Nested Tags
- C.117. ZendGuardEncodeTask
- C.117.1. Example
- C.117.2. Supported Nested Tags
- C.118. ZendGuardLicenseTask
- C.118.1. Examples
- C.119. ZipTask
- C.119.1. Example
- C.119.2. Supported Nested Tags
- C.120. ZSDTPackTask
- C.120.1. Example
- C.121. ZSDTValidateTask
- C.121.1. Example
- D. Core Types
- D.1. Description
- D.1.1. Usage Examples
- D.2. Excludes
- D.2.1. Nested tags
- D.2.2. Usage Examples
- D.3. FileList
- D.3.1. Usage Examples
- D.4. FileSet
- D.4.1. Using wildcards
- D.4.2. Usage Examples
- D.4.3. Nested tags
- D.4.4. Related types
- D.5. DirSet
- D.5.1. Using wildcards
- D.5.2. Usage Examples
- D.5.3. Nested tags
- D.5.4. Related types
- D.6. PatternSet
- D.6.1. Usage Example
- D.6.2. Nested tags
- D.7. Path / Classpath
- D.7.1. Nested tags
- D.8. PearPackageFileSet
- D.8.1. Usage Examples
- D.8.2. Nested tags
- E. Core filters
- E.1. PhingFilterReader
- E.1.1. Nested tags
- E.1.2. Advanced
- E.2. ExpandProperties
- E.3. ConcatFilter
- E.4. HeadFilter
- E.5. IconvFilter
- E.6. Line Contains
- E.6.1. Nested tags
- E.7. LineContainsRegexp
- E.7.1. Nested tags
- E.8. PrefixLines
- E.9. ReplaceTokens
- E.9.1. Nested tags
- E.10. ReplaceTokensWithFile
- E.10.1. Nested tags
- E.11. ReplaceRegexp
- E.11.1. Nested tags
- E.12. SortFilter
- E.13. StripLineBreaks
- E.14. StripLineComments
- E.14.1. Nested tags
- E.15. StripPhpComments
- E.16. StripWhitespace
- E.17. TabToSpaces
- E.18. TailFilter
- E.19. TidyFilter
- E.19.1. Nested tags
- E.20. XincludeFilter
- E.21. XsltFilter
- E.21.1. Nested tags
- F. Core mappers
- F.1. Common Attributes
- F.2. ChainedMapper
- F.2.1. Examples
- F.3. CompositeMapper
- F.3.1. Examples
- F.4. FirstMatchMapper
- F.4.1. Examples
- F.5. CutDirsMapper
- F.5.1. Examples
- F.6. FlattenMapper
- F.6.1. Examples
- F.7. GlobMapper
- F.7.1. Examples
- F.8. IdentityMapper
- F.9. MergeMapper
- F.9.1. Examples
- F.10. RegexpMapper
- F.10.1. Examples
- G. Core selectors
- G.1. Contains
- G.2. Date
- G.3. Depend
- G.4. Depth
- G.5. Different
- G.6. Filename
- G.7. Present
- G.8. Containsregexp
- G.9. Size
- G.10. Type
- G.11. And
- G.12. Majority
- G.13. None
- G.14. Not
- G.15. Or
- G.16. Readable
- G.17. Writable
- G.18. Executable
- G.19. Selector
- G.20. Symlink Selector
- H. Project Components
- H.1. Phing Projects
- H.1.1. Example
- H.1.2.
- H.1.3. Attributes
- H.2. Targets
- H.2.1. Example
- H.2.2. Attributes
- I. Loggers and Listeners
- I.1. Listeners
- I.2. Loggers
- I.3. DefaultLogger
- I.4. MailLogger
- I.5. NoBannerLogger
- I.6. ProfileLogger
- I.7. StatisticsListener
- I.8. TimestampedLogger
- J. File Formats
- J.1. Build File Format
- J.2. Property File Format
- Bibliography
- International Standards
- Licenses
- Open Source Projects
- Manuals
- Other Resources