Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 03-28-2012, 04:55 PM   #1
Beta Member
Join Date: Mar 2012
Location: United States
Posts: 1
Default Fork Question

I'm not really sure how this fork() method works in java. For example, here's some pseudocode:

main () {
******* fork();
******* fork();
******* fork();
******* print “DONE”;

What would be the outcome of that?

bcomputer is offline   Reply With Quote
Old 03-29-2012, 06:10 AM   #2
Fully Optimized
strollin's Avatar
Join Date: Mar 2011
Location: USA
Posts: 2,319
Default Re: Fork Question

The pseudocode would look more like:

main() {

join() {
print "Done";

There needs to be a way for the code to know when the forked processes are complete so the join does that. It's more complicated than that but that's the gist of it.

This is the way it's usually explained:

Result solve(Problem problem) {
    if (problem is small)
       directly solve problem
    else {
       split problem into independent parts
       fork new subtasks to solve each part
       join all subtasks
       compose result from subresults
strollin is offline   Reply With Quote

fork, java

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 06:13 AM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0