Java: Difference between revisions
No edit summary |
(Started to add material on parallelism in Java.) |
||
Line 1: | Line 1: | ||
Java is a general-purpose, high-level, object-oriented programming language developed in 1995 by Sun Microsystems (purchased by Oracle in 2010). One of the principal design goals for Java was a high degree of portability across platforms, summarized by the slogan ''write once, run anywhere'', and which is realized by having Java source code compiled to 'byte code' which then runs inside a Java virtual machine (JVM), ensuring a very uniform environment across numerous architectures and platforms. This has made Java a popular language choice in some environments and it is also widely used as a language for teaching programming. While performance was not one of the original design goals for Java, there are ways to help Java code run quickly and it has enjoyed a certain popularity in some scientific domains such as the life sciences, e.g. software like the Broad Institute's [https://software.broadinstitute.org/gatk/ GATK]. This page is not designed to teach the Java programming language but merely to provide some tips and hints for the use of Java in a high-performance computing environment such as Compute Canada. | Java is a general-purpose, high-level, object-oriented programming language developed in 1995 by Sun Microsystems (purchased by Oracle in 2010). One of the principal design goals for Java was a high degree of portability across platforms, summarized by the slogan ''write once, run anywhere'', and which is realized by having Java source code compiled to 'byte code' which then runs inside a Java virtual machine (JVM), ensuring a very uniform environment across numerous architectures and platforms. This has made Java a popular language choice in some environments and it is also widely used as a language for teaching programming. While performance was not one of the original design goals for Java, there are ways to help Java code run quickly and it has enjoyed a certain popularity in some scientific domains such as the life sciences, e.g. software like the Broad Institute's [https://software.broadinstitute.org/gatk/ GATK]. This page is not designed to teach the Java programming language but merely to provide some tips and hints for the use of Java in a high-performance computing environment such as Compute Canada. | ||
= | ==Parallelism in Java== | ||
==The <tt>volatile</tt> Keyword== | ===Threading=== | ||
Java includes built-in support for threading, obviating the need for separate interfaces and libraries like OpenMP, pthreads and Boost threads used in other languages. The principal Java object for handling concurrency is the <tt>Thread</tt> class which a programmer can use by either providing a <tt>Runnable</tt> method to the standard <tt>Thread</tt> class or by subclassing the <tt>Thread</tt> class. | |||
===MPI and Java=== | |||
==Pitfalls== | |||
===The <tt>volatile</tt> Keyword=== | |||
This keyword has a sense very different from that used in C/C++. In Java <tt>volatile</tt> when applied to a variable has the effect of ensuring that its value is always read from and written to main memory. | This keyword has a sense very different from that used in C/C++. In Java <tt>volatile</tt> when applied to a variable has the effect of ensuring that its value is always read from and written to main memory. |
Revision as of 19:35, 8 November 2016
Java is a general-purpose, high-level, object-oriented programming language developed in 1995 by Sun Microsystems (purchased by Oracle in 2010). One of the principal design goals for Java was a high degree of portability across platforms, summarized by the slogan write once, run anywhere, and which is realized by having Java source code compiled to 'byte code' which then runs inside a Java virtual machine (JVM), ensuring a very uniform environment across numerous architectures and platforms. This has made Java a popular language choice in some environments and it is also widely used as a language for teaching programming. While performance was not one of the original design goals for Java, there are ways to help Java code run quickly and it has enjoyed a certain popularity in some scientific domains such as the life sciences, e.g. software like the Broad Institute's GATK. This page is not designed to teach the Java programming language but merely to provide some tips and hints for the use of Java in a high-performance computing environment such as Compute Canada.
Parallelism in Java[edit]
Threading[edit]
Java includes built-in support for threading, obviating the need for separate interfaces and libraries like OpenMP, pthreads and Boost threads used in other languages. The principal Java object for handling concurrency is the Thread class which a programmer can use by either providing a Runnable method to the standard Thread class or by subclassing the Thread class.
MPI and Java[edit]
Pitfalls[edit]
The volatile Keyword[edit]
This keyword has a sense very different from that used in C/C++. In Java volatile when applied to a variable has the effect of ensuring that its value is always read from and written to main memory.