How to Use the thread

Source: Internet
Author: User
Tags constant definition netbeans

The Thread is an indispensable part in the development of J2SE. J2SE inherits the Runnable interface in java. lang and the Thread class in J2SE. However, due to the special nature of
Some APIs are removed from the program, and there is no thread group concept or daemon thread.
Today, we will start from an example to learn the concept of a thread in the j2-based architecture. The example we selected is Tetris. First, there are some precautions:
1. Note that do not use floating-point numbers in j2s so that they can be compiled but not pre-verified. Generally, handheld devices cannot handle the high load of floating point operations.
2. the vast majority of the space in the program is occupied by images. We can see that our example today does not have any images, only 5 k. If it is a development product, images are inevitable,
However, try to use a png image with a high compression ratio, and do not be too complicated, because a complicated image will make the image very large.
3. use constants, especially location information, in the program as much as possible, so that you only need to change the quantity when it is modified, and it will reduce the workload when it is transplanted to other platforms. and the color.
Information and so on. You do not need to re-construct it every time you remember it, because the color in j2se is not the same as that in j2se. There is no constant definition.
4. copyright protection is often required for game products. Many decompilation tools can easily decompile the content of jar files. Therefore, you can blur the program to prevent decompilation.
You cannot understand the problem after decompiling. You can right-click the project, select Build | Obfuscating from the properties, and select the Blur level.
5. We use NetBeans as the development platform. For installation instructions, visit www.netbeans.org.
Okay. Let's get started.
A. First, create A new mobile application project named Tetris. Do not create A Hello program automatically. Select MIDP1.0 and CLDC1.0.
B. Create a New Package by right-clicking the project and selecting New | Java Package, named Tetris.
C. Create a New Midlet, same as above. Select New | Java Midlet and name it TetrisMidlet.
D. We need a Canvas that can display the game. Therefore, a new Class named TetrisCanvas is created. In TetrisMidlet. java, TetrisCanvas is used as the currently displayed element:
The current TetrisMidlet. java is as follows:
Package Tetris;

Import javax. microedition. midlet .*;
Import javax. microedition. lcdui .*;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.