Tỗi đã từng sai, và sự trả giá đó nằm ở hiện tại. Không thể ngờ là nó đã xảy ra trong vài năm nay thôi, và nhận thức đã rất khác.Mỗi lần nghĩ về nó lại cảm thấy bản thân thật ngu ngốc, dại dột và thật sự xấu hổ về nó. Rồi ngày… Continue reading 4/23/2017
Thread head first (2)
ß The static Thread.sleep() method forces a thread to leave the running state for at least the duration passed to the sleep method. Thread.sleep(200) puts a thread to sleep for 200 milliseconds. ß The sleep() method throws a checked exception (InterruptedException), so all calls to sleep() must be wrapped in a try/catch, or declared. ß… Continue reading Thread head first (2)
Thread head first
ß A thread with a lower-case ‘t’ is a separate thread of execution in Java. ß Every thread in Java has its own call stack. ß A Thread with a capital ‘T’ is the java.lang.Thread class. A Thread object represents a thread of execution. ß A Thread needs a job to do. A Thread’s job… Continue reading Thread head first
Network connection
Client and server applications communicate over a Socket connection. A Socket represents a connection between two applications which may (or may not) be running on two different physical machines. A client must know the IP address (or domain name) and TCP port number of the server application. A TCP port is a 16-bit unsigned number… Continue reading Network connection
Binary, Decimal, Hexdecimal
Decimal : 0 1 2 3 4 5 6 7 8 9 Hexdecimal: 0 1 2 3 4 5 6 7 8 9 A(10) B(11) C(12) D(13) E(14) F(15) . Ex: Hex -> Dec (0x6ef –> 6*(16^2) + 15*(16^1) + 16*(16^0) == 1792) Binary : 0 1
Format String
%d : decimal. Ex: format(“%d”,42); %f: floating point. Ex: format(“%.3f”,42.000); %x: hexadecimal. Ex: format(“%x”,42); %c: character. Ex: format(“%c”,42); Date and time: Key Calendar methods: add(int field, int amount): add and subtracts time from calendar’s field. get(int field): return the value of the given calendar’s field. getInstance(): return a Calendar, you can specify a locale. getTimeInMillis():… Continue reading Format String
Static variable, Instance variable, Static initializer
Static variable depends on the class loaded. Instance variable depends on the instance loaded (object created) of class. A static initializer is a block of code that runs when a class is loaded, before any other code can use the class, so it’s a great place to initialize a static final variable. A static method… Continue reading Static variable, Instance variable, Static initializer
Object creation, Object death
$ Instance variables live within the object they belong to, on the Heap. $ If the instance variable is a reference to an object, both the reference and the object it refers to are on the Heap. $ A constructor is the code that runs when you say new on a class type. $ A… Continue reading Object creation, Object death
Common status code
• 200 OK: Request succeeded and the information is returned in the response. • 301 Moved Permanently: Requested object has been permanently moved; the new URL is specified in Location: header of the response message. The client software will automatically retrieve the new URL. • 400 Bad Request: This is a generic error code indicating… Continue reading Common status code
Computer network Top Down approach 1.1.2
We can also describe the Internet from an entirely different angle—namely, as an infrastructure that provides services to applications. These applications include electronic mail, Web surfing, social networks, instant messaging, Voiceover-IP (VoIP), video streaming, distributed games, peer-to-peer (P2P) file sharing, television over the Internet, remote login, and much, much more. The applications are said to be distributed applications,… Continue reading Computer network Top Down approach 1.1.2