Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Java threads in the life cycle     - Monitoring services are running properly and will email alert (Server)

- Disk Management LVM (Linux)

- Https (SSL / TLS) Detailed principles (Server)

- Spring next ActiveMQ combat (Programming)

- Learning OpenCV: (VS2010-openCV2.4.3-win7 configuration instructions) (Linux)

- Ubuntu manually set the DSL broadband connection (Linux)

- Node.js developers must know four JavaScript concepts (Programming)

- Good wireless network security information spread in the air (Linux)

- ActiveMQ5.11.1 and JDK version matching relation (Linux)

- Servlet life cycle works (Programming)

- Using nmcli commands to manage network in RedHat / CentOS 7.x (Linux)

- Java singleton mode (Singleton mode) (Programming)

- Iptables Instructions (Linux)

- Ubuntu users install the video driver Nvidia Driver 334.21 (Linux)

- Cacti Linux-based system monitoring and alarm (Linux)

- LVM management reduces swap partition space to the root partition (Linux)

- CentOS 7.0 running Docker kernel error solution (Server)

- How to create a bootable USB disk to use MultiSystem on Ubuntu (Linux)

- How to add and delete bookmarks in Ubuntu (Linux)

- Ubuntu 14.04 Boot Repair (Linux)

 
         
  Java threads in the life cycle
     
  Add Date : 2017-01-08      
         
         
         
  First, a brief look at the thread:

Process: the running program. In fact, the process is a memory allocation space application runtime.

Thread: in fact, in the process of an execution path. The process is responsible for labeling applications space. The thread is responsible for the implementation of the order of application.

Lifetime of the thread:

Generally there are about several thread state:

1. New:

Create a thread object.

2. Ready:

start method is called, the thread execution qualifications obtained, but no enforcement power.

(Principle of randomness: as fast cpu caused by switching, which thread the implementation of the right to obtain the cpu, which thread is executed.)

3. Run:

Thread acquires execution of the CPU, this state has also qualified to perform the execution right.

4. blocking:

Since some operations so that the thread is in the state, there is no implementation of qualifications, nor enforcement powers. While others operate and threads can be activated and activated in a ready state.

5. Death:

run method ends, the thread object becomes garbage, waiting GC recovery.

And then tell us about some of the ways the way the thread:

void run () method inherited Thread or implement must be implemented when Runnable, which writes time-consuming.

void start () method to open thread

static void sleep (long t) releases the execution right of the CPU, does not release the lock

static void sleep (long millis, int nanos)

final void wait () releases the execution right of the CPU, the lock is released

final void notify () wake up at any of a thread pool thread

interrupt (): the interrupt thread.

setPriority (int newPriority): set the thread priority. (The default priority is 5)

getPriority (): Returns the thread's priority.

toString (): Returns a string representation of this thread, including the thread's name, priority, and thread group.

Thread.yield (): Pause the currently executing thread object, and perform other threads. Polite Thread

setDaemon (true): Marks this thread as either a daemon thread or a user thread. When a thread running are all daemon threads, Java virtual machine exit. This method must be called before the thread is started.

join: Join a thread, when the thread execution will be performed after another thread.
     
         
         
         
  More:      
 
- CentOS7 set boot directly into the command line interface (Linux)
- JavaScript closures and the scope chain (Programming)
- How to upgrade to Ubuntu 14.04 Ubuntu 14.10 (Linux)
- Java memory analysis tool uses detailed MAT (Programming)
- Binary tree and some basic operations with binary list (Programming)
- Java static internal class (Programming)
- HBase cluster installation and deployment (Server)
- Oracle 11g modify MEMORY_TARGET (Database)
- Linux Nginx installation and configuration instructions (Server)
- Remote installation of Net-SNMP whole process (Linux)
- Implement Oracle dynamic registration of non-standard port 1521 (Database)
- Hibernate learning introductory tutorial (Programming)
- Troubleshooting Linux virtual machine device id and the letter of inconsistencies (Linux)
- Ubuntu 15.04 / CentOS 7.0 to set custom boot (Linux)
- Three binary tree traversal (recursive, non-recursive traversal and Morris) (Programming)
- Preliminary understanding of SELinux security management (Linux)
- open V switch port mirror in OpenStack neutron (Server)
- Seven kinds of DDoS attack methods and techniques Defensive (Linux)
- VNC configuration detailed analysis under Linux (Linux)
- In addition to wget and curl, what better alternatives (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.