Core Java Category

How Do I Share a HttpURLConnection Sessions across Multiple Requests

HttpURLConnection is subclass of URLConnection with support for HTTP-specific features, for example: open a connection, retrieve message and post data to server.

java coding standards and best practices (2)

1.1 java coding standards and best practices Module Organization The term module in this context refers to a source file. A source file should contain one public class; it may contain additional non-public classes. So java coding standards is basically refer to java source files. When coding source file is our best practices time(Best practice […]

Java coding style guidelines, why need?

 Java coding style to help ensure a uniformly high source code quality, so we always need to review our code keep readable, understandable. clearfully check every lines coding style. this article summarizes why Java coding style and guidelines is so much important?  and next articles we will get some detail rules and guiding principles to archieve this goal.

Why we need to use Multiple Threads?

Why Use Multiple Threads? In many situations, having more than one thread running in a program is beneficial. Here’s a more in-depth look at why this can be good. Better Interaction with the User If only one thread was available, a program would be able to do only one thing at a time. In the […]

Whats these Time-consuming Operations in java

How do I Stop/Suspend a Java Thread

If using methods stop/suspend to stop a thread, this is unsafe and thus deprecated. If a thread being stopped now is modifying common data, that common data remains in an inconsistent state. However, 3 solutions is available as following: 1. let the method run() of the thread finishes itself, it’s best and have no any unsafe […]

What Is a Thread?

When a modern operating system wants to start running a program, it creates a new process. A process is a program that is currently executing. Every process has at least one thread running within it. Sometimes threads are referred to as lightweight processes. A thread is a path of code execution through a program, and […]

How Do I Easily Mock Java Socket Server

As a developer, we have to ensure that our codes are high-quality, fully tested and peer-reviewed before delivering. Today the topic is how to mock java socket server to test Socket related application. Mock  Overview: Mock technology is primarily used to mock applications which are not easily to build in the structure (such as HttpServletRequest […]

Java Interview Questions and Answers

I have summarized some common java interview questions and answers as showed below, you may take a look if you are preparing an interview: 1, what’s  the difference for Error and Exception? Error specifies system-level errors that you can’t handle it. Exception specifies program-level exception that you can catch it. 2.  if A class is declared as final […]

How to Mock a Static Method with EasyMock ?

The goal of unit testing is to test the code behaved as exactly expected and smallest piece of testable software as possible, the approach to do so is use mock technology that code becomes independent, lets thing goes to easy. EasyMock provides Mock Objects for interfaces by generating them on the fly using Java’s proxy […]