Results 1 to 20 of 24
Thread: is it mutithreading?
- 10-06-2010, 06:27 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 17
- Rep Power
- 0
is it mutithreading?
hi!
if i run same program (say its name is "hello" in file hello.java) with two different "java" commands as:
>java hello rajinder
>java hello prince
where rajinder and prince are command line arguments.
is this multithreading??? ...i mean the two java commands will run the same hello program as two different processes or as the two different threads of same program???
thanks in advance...
- 10-06-2010, 06:52 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
You could try try reading and writing some static data in the Hello class.
- 10-06-2010, 07:36 AM #3
Member
- Join Date
- Oct 2010
- Posts
- 7
- Rep Power
- 0
When you run the same program twice in parallel, these are usually called processes, not threads. Threads are understood as parts of the same Java virtual machine that share most of the accessible memory (processes normally run in dedicated memory space and may only share tiny parts for data exchange). Hence thread is more lightweight than a process.
If you modify static fields in one process, this should have no any effect on the field values in another process. It does not matter that classes are loaded from the same files. Only system classes may be shared in some advanced implementations but this is likely done in a transparent way.Last edited by audriusa; 10-06-2010 at 07:39 AM.
- 10-06-2010, 09:50 AM #4
Member
- Join Date
- Oct 2010
- Posts
- 17
- Rep Power
- 0
is running two "java" commands means running two different JVMs???
- 10-06-2010, 10:32 AM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
- 10-07-2010, 11:50 AM #6
Senior Member
- Join Date
- Mar 2010
- Location
- Manila, Philippines
- Posts
- 257
- Rep Power
- 4
- 10-08-2010, 03:00 PM #7
Member
- Join Date
- Oct 2010
- Posts
- 17
- Rep Power
- 0
thanks for responding... :)
- 10-11-2010, 04:33 PM #8
Member
- Join Date
- Oct 2010
- Posts
- 17
- Rep Power
- 0
like "java", will "javac" also counted under JVM... i mean is it also part of JVM??
JVM's work is to load the classes and execute them. is compiling the java programs to bytecode also considered as the work of JVM???
thanks...
- 10-11-2010, 04:52 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
Nope, the compiler can be written in BrainF*ck (*) for that matter, as long as it produces valid classes. It is a good tradition to write a compiler for a language X in language X itself and so is javac written in Java but it is not part of the jvm.
kind regards,
Jos
(*) I sincerely doubt that anyone can write a compiler in BrainF*ck ;-)
- 10-11-2010, 11:27 PM #10
Member
- Join Date
- May 2010
- Posts
- 27
- Rep Power
- 0
This isn't multithreading. This is just running two processes. If you have two threads going, they're in the same process. Threads cannot be called from command prompt, only from within the JVM.
- 10-12-2010, 08:16 AM #11
Member
- Join Date
- Oct 2010
- Posts
- 17
- Rep Power
- 0
hi!
dear JosAH! perhaps u only can write compiler in BrainF*ck language and i m sure u will write one day. ;-) i definitely cannot!!!
by the way, can an application have multiple processes running at the same time like multiple threads??? i mean ... do concurrently running processes always belong to different applications/programs(like winword and winamp) or they can also belong to same applications(winword only)???
thanks...
- 10-12-2010, 08:50 AM #12
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Processes belong to the OS.
Threads belong to a process (program).
I can write a program that'll launch a load of processes and then exit and those processes could (depending on what they do) still be running.
I could also write a program that creates a load of Threads, but when that Java process exits so do those threads.
- 10-13-2010, 10:03 AM #13
Member
- Join Date
- Oct 2010
- Posts
- 17
- Rep Power
- 0
hi Tolls!!!
do u mean that a program/application(say WINWORD) can have multiple processes running concurrently within it and each process, in turn, can have multiple threads running in it concurrently???
- 10-13-2010, 10:06 AM #14
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
No.
Your WINWORD is a process.
It might launch other processes (in Java via the runtime exec() stuff), but it doesn't own them.
- 10-14-2010, 01:35 AM #15
Member
- Join Date
- May 2010
- Posts
- 27
- Rep Power
- 0
Yah. Winword can have multiple threads... probably does. That way one thread can listen for keystrokes while another handles screen output. That would mean that keystrokes aren't lost during a lag.
My computer is running on 790 threads and 68 processes. If that says anything...
- 10-14-2010, 08:21 AM #16
Member
- Join Date
- Oct 2010
- Posts
- 17
- Rep Power
- 0
so do u mean that processes always belong to OS i.e. all applications or softwares( eg winword ,winamp, media players etc.) running on an OS (say windows platform) are procesess and each such process can have multiple threads???
- 10-14-2010, 08:58 AM #17
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
You probably ought to go and read up on this properly, since you seem to want something detailed.
My stuff above is a basic rule of thumb (or ROT if you prefer), and done froma Java perspective (this is after all a Java forum). For example, a Unix command window can own several processes, and it is itself a process. So if the terminal is closed then those processes are often shutdown as well, though they can be orphaned (essentially taken over by the OS). It's not as clearcut as I'm making out.
But, a thread (in Java terms) is owned by the program, and dies with the program. A process does not (in Java terms)...necessarily.
- 10-15-2010, 08:40 AM #18
Member
- Join Date
- Oct 2010
- Posts
- 17
- Rep Power
- 0
thanks tolls!!!
one question regarding "locks/monitors".
suppose a thread acquire class lock on a class named "xyz" . is this same as acquiring lock on xyz.class (instance of class Class)???
- 10-15-2010, 08:59 AM #19
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
I think so, but you'd do better to get someone more used to synchronising than me. I try and avoid getting myself into the position of needing stuff like that.
- 10-15-2010, 09:33 AM #20
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks