MESSAGE
DATE | 2015-03-25 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] Java Crimes
|
This is just my opinion and I don't really care how many people disagreee, but java is a stupid programming language.
Read this spec. It looks like it came out of Green Eggs and Ham
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` Threads are the fundamental model of program execution in a Java program, and the Java language and its API provide a rich set of features for the creation and management of threads. All Java programs comprise at least a single thread of control—even a simple Java program consisting of only a main() method runs as a single thread in the JVM. Java threads are available on any system that provides a JVM including Windows, Linux, and Mac OS X. The Java thread API is available for Android applications as well. There are two techniques for creating threads in a Java program. One approach is to create a new class that is derived from the Thread class and to override its run() method. An alternative —and more commonly used — technique is to define a class that implements the Runnable interface. The Runnable interface is defined as follows: public interface Runnable { public abstract void run(); } When a class implements Runnable, it must define a run() method. The code implementing the run() method is what runs as a separate thread.
Figure 4.12 shows the Java version of a multithreaded program that determines the summation of a non-negative integer. The Summation class implements the Runnable interface. Thread creation is performed by creating an object instance of the Thread class and passing the constructor a Runnable object. ***Creating a Thread object does not specifically create the new thread; rather, the start() method creates the new thread. Calling the start() method for the new object does two things: 1.2.It allocates memory and initializes a new thread in the JVM. It calls the run() method, making the thread eligible to be run by the JVM.
***(Note again that we never call the run() method directly. Rather, we call the start() method, and it calls the run() method on our behalf.)***
ehhhh... feh
|
|