Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #18359

Re: thread vs fork?

Newsgroups comp.lang.java.programmer
Date 2012-08-28 13:54 -0700
References <15cf029d-e8bc-47de-8b83-44e70247d381@googlegroups.com> <euto38td1cm90mg7qg11b2375oh925hj7q@4ax.com>
Message-ID <dca1d3b6-47f2-4145-8797-b2b720af1bcb@googlegroups.com> (permalink)
Subject Re: thread vs fork?
From Lew <lewbloch@gmail.com>

Show all headers | View raw


Roedy Green wrote:
> Peter Cheung wrote, quoted or indirectly quoted someone who said:
>>hi, is fork runs faster then thread in java?
> 

> There is obviously less overhead with a new thread than forking off a
> new process.  A thread shares the same pool of objects.  A fork has

What does that have to do with Java?

In Java the exact opposite is true:
http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ForkJoinTask.html
"
Abstract base class for tasks that run within a ForkJoinPool. A ForkJoinTask is a thread-like entity that is much lighter weight than a normal thread. Huge numbers of tasks and subtasks may be hosted by a small number of actual threads in a ForkJoinPool, at the price of some usage limitations."

> its own JVM and pool of objects.    Forking is usually to code you had
> nothing to do with writing or that is written in other languages.

Unless, of course, you are talking about forking in the Java sense.

> Threads are when the piece of work to do is quite small

No, that's not true at all.

Threads are just fine when the piece of work is large, and in many cases
are motivated by the need to do large pieces of work. The whole idea of 
'SwingWorker', for example, is to perform large units of work in a different 
thread from the GUI.

> or needs access to your object pool. 

That is true, assuming you need concurrency.

Well, partially true. In many cases there are non-thread solutions.

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

thread vs fork? Peter Cheung <cmk128@gmail.com> - 2012-08-25 23:40 -0700
  Re: thread vs fork? "John B. Matthews" <nospam@nospam.invalid> - 2012-08-26 03:27 -0400
  Re: thread vs fork? Arne Vajhøj <arne@vajhoej.dk> - 2012-08-26 09:34 -0400
  Re: thread vs fork? Roedy Green <see_website@mindprod.com.invalid> - 2012-08-28 00:52 -0700
    Re: thread vs fork? Lew <lewbloch@gmail.com> - 2012-08-28 13:54 -0700
      Re: thread vs fork? Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-08-28 19:08 -0500
        Re: thread vs fork? Lew <lewbloch@gmail.com> - 2012-08-28 17:48 -0700
          Re: thread vs fork? Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-08-28 20:01 -0500
            Re: thread vs fork? Lew <lewbloch@gmail.com> - 2012-08-29 11:01 -0700

csiph-web