Automatically return the object pool-a legend that is not beautiful

Source: Internet
Author: User

An object pool that is automatically returned-a legend that is not beautiful

There is a beautiful legend that a beautiful stone will sing ........
What a fascinating thing (no need to buy mp3), since even the stone will sing, so too many legends were born.

In issue 11th, programmer magazine published an article entitled <automatically returned Object pool>. The author described a wonderful
The object pool that can be automatically returned makes every programmer suffering from garbage collection heart-warming.

But will the legend come true?

After reading the entire article, I did not find a line of schematic implementation code. All the code snippets only demonstrate the principle of getting recyclable objects.
For example, I want to introduce you to a high-performance httpserver. Then I will tell you:

Serversocket SC = new serversocket (80 );
In this way, you can listen to HTTP request links on port 80.

Know that serversocket SC = new serversocket (80) can be written, and can be written into practical applications.
How many people are there on webserver? I'm afraid the author is just a dream.

This is not important, because after all, some people can turn the legend into a reality, or we have WebLogic, resin, Tomcat ("ghost Column
Not more than three "is a moral) available, but the legends that can become reality are not all beautiful.

Java is an object-oriented idea. Java programming is a process of understanding nature.
Life and death make the whole world not only operate normally, but also keep growing constantly. If there is an undead technique (not only does this mean
Programmers are yearning.) After that, one hundred years ago, everyone was in an awkward state. What is the world?

Every Java object has its life cycle. The life cycle of an object is not only managed by JVM, but also by the job system.
Restrictions of the protocol specification. The author has been using the connection object as a description in his essay, and we also use the connection object
The legend is not beautiful for it.

We know that the real connection pool achieves the contraction function, that is, if the link is idle for a certain period of time
After a certain period of time, we will destroy it and generate a new connection when necessary. It is in this way that the connection can be made through a proper means of life and death.
The pool works normally.
If it is said that connection is a reality, it will never die. When it is idle, it will always be connected to the database.
The number of connections that a database can connect to is limited. In this way, when this application is not required, other applications cannot
There are too many opportunities to connect. connecion is like a car. You have applied for 40 vehicles at a time. No matter you don't need them, you have always been so occupied.
I want to use it. The actual connection pool is that if I only need 10 vehicles, I will return 30 vehicles first, and apply again when I need them.
The death of connecion, giving other applications the opportunity to establish connections, is a principle that ethical programmers should follow.
Whether the connection needs to be kept alive.

On the other hand, if the object exceeds its life cycle, even if it is forced to keep him alive, it is just walking dead, no
Why does a living object force him to survive? The trash of history indicates that it has completed its mission and forced
They are recycled from the garbage and reused. What are the terrible scenes of the ghost resurrection that everyone has seen on the screen?

It is also explained by connection (the original author has always stated this object), and its lifecycle is not only
JVM management, and it is also restricted by the TCP protocol. If the contracted connection is hard to be recovered from the garbage collection, we can see that it will
How? If this connection is idle for a long time and does not interact with the database, although as a JVM, it can return garbage
The receiver is retrieved again, but at the protocol layer, the database server suspends the response to the socket connection because it is idle and times out.
Then execute command, "Connection reset by peer: Socket writ", a alive
Life Force (pure protein ).

Life and death are simple and cannot be forced. In the past, Chinese people simply thought that "people win the sky" would not be born.
The mountains of coal are forced to dig holes. We have foreseen or can see the evil effects of changing nature. We are destroying ourselves and adapting ourselves to nature,
Protecting Nature is the legend of true beauty.

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.