markword

注释

该文件目录在:

\openjdk-jdk8u\hotspot\src\share\vm\oops\markOop.hpp

  1. #ifndef SHARE_VM_OOPS_MARKOOP_HPP
  2. #define SHARE_VM_OOPS_MARKOOP_HPP
  3. #include "oops/oop.hpp"
  4. // The markOop describes the header of an object.
  5. //
  6. // Note that the mark is not a real oop but just a word.
  7. // It is placed in the oop hierarchy for historical reasons.
  8. //
  9. // Bit-format of an object header (most significant first, big endian layout below):
  10. //
  11. // 32 bits:
  12. // --------
  13. // hash:25 ------------>| age:4 biased_lock:1 lock:2 (normal object)
  14. // JavaThread*:23 epoch:2 age:4 biased_lock:1 lock:2 (biased object)
  15. // size:32 ------------------------------------------>| (CMS free block)
  16. // PromotedObject*:29 ---------->| promo_bits:3 ----->| (CMS promoted object)

这里咱们翻译下

markOop描述对象头。

注意的是,对象头不是一个真正的oop,而只是一个word(大家可以回想下学计算机基础课程的时候,一个word大概是32字节,64位机器上,则是64字节。)

它只是因为历史原因而被放在oop的继承结构中。

对象头的格式(32字节):

正常时:

25bit的hash---------------------------------- 4bit的 gc 年龄 -------偏向锁标志1个bit------------lock标志,2个bit

偏向时:

23个bit,存放偏向的线程的指针;2bit,存放epoch;4bit,存放gc年龄;1bit,偏向锁标志;2bit,锁标志

cms free block:

跳过,不懂

CMS promoted object(cms提升后的对象,是指从新生代提升到老年代的对象?)

29bit,存放PromotedObject的指针;3bit,存放promo_bits

继续下一段:

  1. // 64 bits:
  2. // --------
  3. // unused:25 hash:31 -->| unused:1 age:4 biased_lock:1 lock:2 (normal object)
  4. // JavaThread*:54 epoch:2 unused:1 age:4 biased_lock:1 lock:2 (biased object)
  5. // PromotedObject*:61 --------------------->| promo_bits:3 ----->| (CMS promoted object)
  6. // size:64 ----------------------------------------------------->| (CMS free block)
  7. //
  8. // unused:25 hash:31 -->| cms_free:1 age:4 biased_lock:1 lock:2 (COOPs && normal object)
  9. // JavaThread*:54 epoch:2 cms_free:1 age:4 biased_lock:1 lock:2 (COOPs && biased object)
  10. // narrowOop:32 unused:24 cms_free:1 unused:4 promo_bits:3 ----->| (COOPs && CMS promoted object)
  11. // unused:21 size:35 -->| cms_free:1 unused:7 ------------------>| (COOPs && CMS free block)

翻译:

  1. 64 bit
  2. 正常对象:
  3. 25bit,未使用;31bithashcode1bit,没使用;4bit,gc年龄;1bit,偏向锁标志;2bit,lock标志
  4. 偏向锁状态时:
  5. 54bit,当前偏向的线程的指针;2bitepoch1bit,没使用;4bitgc年龄;1bit,偏向锁标志;2bit,lock标志
  6. cms提升后的对象:
  7. 61bitPromotedObject*;3bitpromo_bits
  8. cms free obj
  9. 不懂,跳过。

然后我们先说下,上面还有几个没翻译,插播个名词,COOPs,压缩对象指针技术,对象指针压缩在Java SE 6u23 默认开启。在此之前,可以使用-XX:+UseCompressedOops来开启。可以看看这个链接:

https://blog.csdn.net/superfjj/article/details/107455559

ok,我们继续:

  1. //
  2. // unused:25 hash:31 -->| cms_free:1 age:4 biased_lock:1 lock:2 (COOPs && normal object)
  3. // JavaThread*:54 epoch:2 cms_free:1 age:4 biased_lock:1 lock:2 (COOPs && biased object)
  4. // narrowOop:32 unused:24 cms_free:1 unused:4 promo_bits:3 ----->| (COOPs && CMS promoted object)
  5. // unused:21 size:35 -->| cms_free:1 unused:7 ------------------>| (COOPs && CMS free block)

翻译:

  1. 64 bit
  2. 正常对象(和前面没开coops时比,没变化):
  3. 25bit,未使用;31bithashcode1bit,没使用;4bit,gc年龄;1bit,偏向锁标志;2bit,lock标志
  4. 偏向锁状态时(和前面没开coops时比,没变化):
  5. 54bit,当前偏向的线程的指针;2bitepoch1bit,没使用;4bitgc年龄;1bit,偏向锁标志;2bit,lock标志
  6. COOPs && CMS promoted object:
  7. narrowOop:32 unused:24 cms_free:1 unused:4 promo_bits:3
  8. COOPs && CMS free block:
  9. unused:21 size:35 -->| cms_free:1 unused:7
  1. // - hash contains the identity hash value: largest value is
  2. // 31 bits, see os::random(). Also, 64-bit vm's require
  3. // a hash value no bigger than 32 bits because they will not
  4. // properly generate a mask larger than that: see library_call.cpp
  5. // and c1_CodePatterns_sparc.cpp.
  6. //
  7. // - the biased lock pattern is used to bias a lock toward a given
  8. // thread. When this pattern is set in the low three bits, the lock
  9. // is either biased toward a given thread or "anonymously" biased,
  10. // indicating that it is possible for it to be biased. When the
  11. // lock is biased toward a given thread, locking and unlocking can
  12. // be performed by that thread without using atomic operations.
  13. // When a lock's bias is revoked, it reverts back to the normal
  14. // locking scheme described below.
  15. //
  16. // Note that we are overloading the meaning of the "unlocked" state
  17. // of the header. Because we steal a bit from the age we can
  18. // guarantee that the bias pattern will never be seen for a truly
  19. // unlocked object.
  20. //
  21. // Note also that the biased state contains the age bits normally
  22. // contained in the object header. Large increases in scavenge
  23. // times were seen when these bits were absent and an arbitrary age
  24. // assigned to all biased objects, because they tended to consume a
  25. // significant fraction of the eden semispaces and were not
  26. // promoted promptly, causing an increase in the amount of copying
  27. // performed.
  28. // The runtime system aligns all JavaThread* pointers to
  29. // a very large value (currently 128 bytes (32bVM) or 256 bytes (64bVM))
  30. // to make room for the age bits & the epoch bits (used in support of
  31. // biased locking), and for the CMS "freeness" bit in the 64bVM (+COOPs).

翻译:

  1. hash字段,包含了唯一的hash value:最大的值是31bit。另外,64bit的虚拟机时,hash value也不能超过32bit;因为不能恰当地生成一个大于它的掩码。
  2. 偏向锁标志,是用来把一个锁,偏向一个指定的现场。当在最后三位,设置了该模式后,这个锁,要么偏向一个指定的现场,要么被匿名偏向(表示可能被偏向)。当这个锁,被偏向一个指定的线程时,该线程进行加锁和解锁时,无需原子操作(有点费解)
  3. 当该锁的偏向标志被撤销时,它会回到正常的锁定的模式。
  4. 注意,我们这里重载了header中,未锁定状态的意义。因为我们从age中偷了一位,这样我们就可以保证,对于一个真正没被锁定的对象,偏向标志不会被看到。
  5. 译者补充:我们再把偏向标志的拿过来看一下:
  6. // JavaThread*:54 epoch:2 cms_free:1 age:4 biased_lock:1 lock:2 (biased object)
  7. age偷了一位,难道之前age5bit,最大gc年龄32吗,现在4位,所以最大gc年龄为16.
  8. 不是很理解这句话。
  9. 注意的是,偏向状态时,包含了agebit位。当这几个位缺失时,且给所有被偏向对象,赋值一个任意的gc 年龄时,我们会看到,清理垃圾的时间大幅上升,因为他们将消耗一部分的eden空间,且不能被迅速提升到老年代,导致了一定量的拷贝工作(译者:从eden拷贝到s区)。

  1. //
  2. // [JavaThread* | epoch | age | 1 | 01] lock is biased toward given thread
  3. // [0 | epoch | age | 1 | 01] lock is anonymously biased
  4. //
  5. // - the two lock bits are used to describe three states: locked/unlocked and monitor.
  6. //
  7. // [ptr | 00] locked ptr points to real header on stack
  8. // [header | 0 | 01] unlocked regular object header
  9. // [ptr | 10] monitor inflated lock (header is wapped out)
  10. // [ptr | 11] marked used by markSweep to mark an object
  11. // not valid at any other time
  12. //
  13. // We assume that stack/thread pointers have the lowest two bits cleared.

翻译:

  1. lock偏向某个线程时:
  2. [JavaThread* | epoch | age | 1 | 01]
  3. lock is anonymously biased(可能被偏向时)
  4. [0 | epoch | age | 1 | 01]
  5. 后面的两位,被用来描述三种状态:锁定、未锁定、monitor
  6. 锁定时:
  7. [ptr | 00]
  8. ptr指向一个栈上的header
  9. 未锁定时:
  10. [header | 0 | 01]
  11. header就是常规的对象头
  12. monitor时:
  13. [ptr | 10]
  14. ptr指向膨胀后的lock header被包装起来了
  15. marked
  16. [ptr | 11] marked
  17. markSweep,即标记清理时使用,标记一个对象无效

正文

以下为全文,下面的1处,我先讲解下,这个定义了一个field:

  1. uintptr_t value()

我也不熟c++,查了一下,https://blog.csdn.net/cs_zhanyb/article/details/16973379

在64位的机器上,intptr_t和uintptr_t分别是long int、unsigned long int的别名;在32位的机器上,intptr_t和uintptr_t分别是int、unsigned int的别名。

也就是说,在64位机器上,这个类型代表了unsigned long int,那既然是long,肯定是64位了,也就是说,此时它就是个无符号的long类型;

32位上,则代表了unsigned int,此时,它就是个无符号的int(32位)。

有同学问我,锁膨胀时,指向objectmonitor的指针在哪里,ok,就是在这个里面。

大家继续看下面:

  1. class BasicLock;
  2. class ObjectMonitor;
  3. class JavaThread;
  4. class markOopDesc: public oopDesc {
  5. private:
  6. // Conversion
  7. // 1
  8. uintptr_t value() const { return (uintptr_t) this; }
  9. public:
  10. // Constants
  11. enum { age_bits = 4,
  12. lock_bits = 2,
  13. biased_lock_bits = 1,
  14. max_hash_bits = BitsPerWord - age_bits - lock_bits - biased_lock_bits,
  15. hash_bits = max_hash_bits > 31 ? 31 : max_hash_bits,
  16. cms_bits = LP64_ONLY(1) NOT_LP64(0),
  17. epoch_bits = 2
  18. };
  19. // The biased locking code currently requires that the age bits be
  20. // contiguous to the lock bits.
  21. enum { lock_shift = 0,
  22. biased_lock_shift = lock_bits,
  23. age_shift = lock_bits + biased_lock_bits,
  24. cms_shift = age_shift + age_bits,
  25. hash_shift = cms_shift + cms_bits,
  26. epoch_shift = hash_shift
  27. };
  28. enum { lock_mask = right_n_bits(lock_bits),
  29. lock_mask_in_place = lock_mask << lock_shift,
  30. biased_lock_mask = right_n_bits(lock_bits + biased_lock_bits),
  31. biased_lock_mask_in_place= biased_lock_mask << lock_shift,
  32. biased_lock_bit_in_place = 1 << biased_lock_shift,
  33. age_mask = right_n_bits(age_bits),
  34. age_mask_in_place = age_mask << age_shift,
  35. epoch_mask = right_n_bits(epoch_bits),
  36. epoch_mask_in_place = epoch_mask << epoch_shift,
  37. cms_mask = right_n_bits(cms_bits),
  38. cms_mask_in_place = cms_mask << cms_shift
  39. };
  40. // Alignment of JavaThread pointers encoded in object header required by biased locking
  41. enum { biased_lock_alignment = 2 << (epoch_shift + epoch_bits)
  42. };
  43. enum { locked_value = 0,
  44. unlocked_value = 1,
  45. monitor_value = 2,
  46. marked_value = 3,
  47. biased_lock_pattern = 5
  48. };
  49. enum { no_hash = 0 }; // no hash value assigned
  50. enum { no_hash_in_place = (address_word)no_hash << hash_shift,
  51. no_lock_in_place = unlocked_value
  52. };
  53. enum { max_age = age_mask };
  54. enum { max_bias_epoch = epoch_mask };
  55. // Prototype mark for initialization
  56. static markOop biased_locking_prototype() {
  57. return markOop( biased_lock_pattern );
  58. }
  59. // lock accessors (note that these assume lock_shift == 0)
  60. bool is_locked() const {
  61. return (mask_bits(value(), lock_mask_in_place) != unlocked_value);
  62. }
  63. bool is_unlocked() const {
  64. return (mask_bits(value(), biased_lock_mask_in_place) == unlocked_value);
  65. }
  66. bool is_marked() const {
  67. return (mask_bits(value(), lock_mask_in_place) == marked_value);
  68. }
  69. bool is_neutral() const { return (mask_bits(value(), biased_lock_mask_in_place) == unlocked_value); }
  70. // Special temporary state of the markOop while being inflated.
  71. // Code that looks at mark outside a lock need to take this into account.
  72. bool is_being_inflated() const { return (value() == 0); }
  73. // Distinguished markword value - used when inflating over
  74. // an existing stacklock. 0 indicates the markword is "BUSY".
  75. // Lockword mutators that use a LD...CAS idiom should always
  76. // check for and avoid overwriting a 0 value installed by some
  77. // other thread. (They should spin or block instead. The 0 value
  78. // is transient and *should* be short-lived).
  79. static markOop INFLATING() { return (markOop) 0; } // inflate-in-progress
  80. // Should this header be preserved during GC?
  81. inline bool must_be_preserved(oop obj_containing_mark) const;
  82. inline bool must_be_preserved_with_bias(oop obj_containing_mark) const;
  83. // Should this header (including its age bits) be preserved in the
  84. // case of a promotion failure during scavenge?
  85. // Note that we special case this situation. We want to avoid
  86. // calling BiasedLocking::preserve_marks()/restore_marks() (which
  87. // decrease the number of mark words that need to be preserved
  88. // during GC) during each scavenge. During scavenges in which there
  89. // is no promotion failure, we actually don't need to call the above
  90. // routines at all, since we don't mutate and re-initialize the
  91. // marks of promoted objects using init_mark(). However, during
  92. // scavenges which result in promotion failure, we do re-initialize
  93. // the mark words of objects, meaning that we should have called
  94. // these mark word preservation routines. Currently there's no good
  95. // place in which to call them in any of the scavengers (although
  96. // guarded by appropriate locks we could make one), but the
  97. // observation is that promotion failures are quite rare and
  98. // reducing the number of mark words preserved during them isn't a
  99. // high priority.
  100. inline bool must_be_preserved_for_promotion_failure(oop obj_containing_mark) const;
  101. inline bool must_be_preserved_with_bias_for_promotion_failure(oop obj_containing_mark) const;
  102. // Should this header be preserved during a scavenge where CMS is
  103. // the old generation?
  104. // (This is basically the same body as must_be_preserved_for_promotion_failure(),
  105. // but takes the Klass* as argument instead)
  106. inline bool must_be_preserved_for_cms_scavenge(Klass* klass_of_obj_containing_mark) const;
  107. inline bool must_be_preserved_with_bias_for_cms_scavenge(Klass* klass_of_obj_containing_mark) const;
  108. // WARNING: The following routines are used EXCLUSIVELY by
  109. // synchronization functions. They are not really gc safe.
  110. // They must get updated if markOop layout get changed.
  111. markOop set_unlocked() const {
  112. return markOop(value() | unlocked_value);
  113. }
  114. bool has_locker() const {
  115. return ((value() & lock_mask_in_place) == locked_value);
  116. }
  117. BasicLock* locker() const {
  118. assert(has_locker(), "check");
  119. return (BasicLock*) value();
  120. }
  121. bool has_displaced_mark_helper() const {
  122. return ((value() & unlocked_value) == 0);
  123. }
  124. markOop displaced_mark_helper() const {
  125. assert(has_displaced_mark_helper(), "check");
  126. intptr_t ptr = (value() & ~monitor_value);
  127. return *(markOop*)ptr;
  128. }
  129. void set_displaced_mark_helper(markOop m) const {
  130. assert(has_displaced_mark_helper(), "check");
  131. intptr_t ptr = (value() & ~monitor_value);
  132. *(markOop*)ptr = m;
  133. }
  134. markOop copy_set_hash(intptr_t hash) const {
  135. intptr_t tmp = value() & (~hash_mask_in_place);
  136. tmp |= ((hash & hash_mask) << hash_shift);
  137. return (markOop)tmp;
  138. }
  139. // it is only used to be stored into BasicLock as the
  140. // indicator that the lock is using heavyweight monitor
  141. static markOop unused_mark() {
  142. return (markOop) marked_value;
  143. }
  144. // the following two functions create the markOop to be
  145. // stored into object header, it encodes monitor info
  146. static markOop encode(BasicLock* lock) {
  147. return (markOop) lock;
  148. }
  149. static markOop encode(ObjectMonitor* monitor) {
  150. intptr_t tmp = (intptr_t) monitor;
  151. return (markOop) (tmp | monitor_value);
  152. }
  153. static markOop encode(JavaThread* thread, uint age, int bias_epoch) {
  154. intptr_t tmp = (intptr_t) thread;
  155. assert(UseBiasedLocking && ((tmp & (epoch_mask_in_place | age_mask_in_place | biased_lock_mask_in_place)) == 0), "misaligned JavaThread pointer");
  156. assert(age <= max_age, "age too large");
  157. assert(bias_epoch <= max_bias_epoch, "bias epoch too large");
  158. return (markOop) (tmp | (bias_epoch << epoch_shift) | (age << age_shift) | biased_lock_pattern);
  159. }
  160. // used to encode pointers during GC
  161. markOop clear_lock_bits() { return markOop(value() & ~lock_mask_in_place); }
  162. // age operations
  163. markOop set_marked() { return markOop((value() & ~lock_mask_in_place) | marked_value); }
  164. markOop set_unmarked() { return markOop((value() & ~lock_mask_in_place) | unlocked_value); }
  165. uint age() const { return mask_bits(value() >> age_shift, age_mask); }
  166. markOop set_age(uint v) const {
  167. assert((v & ~age_mask) == 0, "shouldn't overflow age field");
  168. return markOop((value() & ~age_mask_in_place) | (((uintptr_t)v & age_mask) << age_shift));
  169. }
  170. markOop incr_age() const { return age() == max_age ? markOop(this) : set_age(age() + 1); }
  171. // hash operations
  172. intptr_t hash() const {
  173. return mask_bits(value() >> hash_shift, hash_mask);
  174. }
  175. bool has_no_hash() const {
  176. return hash() == no_hash;
  177. }
  178. // Prototype mark for initialization
  179. static markOop prototype() {
  180. return markOop( no_hash_in_place | no_lock_in_place );
  181. }
  182. // Helper function for restoration of unmarked mark oops during GC
  183. static inline markOop prototype_for_object(oop obj);
  184. // Debugging
  185. void print_on(outputStream* st) const;
  186. // Prepare address of oop for placement into mark
  187. inline static markOop encode_pointer_as_mark(void* p) { return markOop(p)->set_marked(); }
  188. // Recover address of oop from encoded form used in mark
  189. inline void* decode_pointer() { if (UseBiasedLocking && has_bias_pattern()) return NULL; return clear_lock_bits(); }
  190. // These markOops indicate cms free chunk blocks and not objects.
  191. // In 64 bit, the markOop is set to distinguish them from oops.
  192. // These are defined in 32 bit mode for vmStructs.
  193. const static uintptr_t cms_free_chunk_pattern = 0x1;
  194. // Constants for the size field.
  195. enum { size_shift = cms_shift + cms_bits,
  196. size_bits = 35 // need for compressed oops 32G
  197. };
  198. // These values are too big for Win64
  199. const static uintptr_t size_mask = LP64_ONLY(right_n_bits(size_bits))
  200. NOT_LP64(0);
  201. const static uintptr_t size_mask_in_place =
  202. (address_word)size_mask << size_shift;
  203. #ifdef _LP64
  204. static markOop cms_free_prototype() {
  205. return markOop(((intptr_t)prototype() & ~cms_mask_in_place) |
  206. ((cms_free_chunk_pattern & cms_mask) << cms_shift));
  207. }
  208. uintptr_t cms_encoding() const {
  209. return mask_bits(value() >> cms_shift, cms_mask);
  210. }
  211. bool is_cms_free_chunk() const {
  212. return is_neutral() &&
  213. (cms_encoding() & cms_free_chunk_pattern) == cms_free_chunk_pattern;
  214. }
  215. size_t get_size() const { return (size_t)(value() >> size_shift); }
  216. static markOop set_size_and_free(size_t size) {
  217. assert((size & ~size_mask) == 0, "shouldn't overflow size field");
  218. return markOop(((intptr_t)cms_free_prototype() & ~size_mask_in_place) |
  219. (((intptr_t)size & size_mask) << size_shift));
  220. }
  221. #endif // _LP64
  222. };
  223. #endif // SHARE_VM_OOPS_MARKOOP_HPP

然后我们讲解下部分方法:

  1. // Biased Locking accessors.
  2. // These must be checked by all code which calls into the
  3. // ObjectSynchronizer and other code. The biasing is not understood
  4. // by the lower-level CAS-based locking code, although the runtime
  5. // fixes up biased locks to be compatible with it when a bias is
  6. // revoked.
  7. // 是否设置了偏向标志
  8. bool has_bias_pattern() const {
  9. return (mask_bits(value(), biased_lock_mask_in_place) == biased_lock_pattern);
  10. }
  11. // 获取偏向的线程的指针
  12. JavaThread* biased_locker() const {
  13. assert(has_bias_pattern(), "should not call this otherwise");
  14. return (JavaThread*) ((intptr_t) (mask_bits(value(), ~(biased_lock_mask_in_place | age_mask_in_place | epoch_mask_in_place))));
  15. }
  16. // Indicates that the mark has the bias bit set but that it has not
  17. // yet been biased toward a particular thread
  18. // 是否可以偏向;但当前还没有偏向任何线程
  19. bool is_biased_anonymously() const {
  20. return (has_bias_pattern() && (biased_locker() == NULL));
  21. }

下面可以看到epoch的简单意思:

如果因为太多次发生偏向锁撤销,那么epoch会发生变化。


  1. // Indicates epoch in which this bias was acquired. If the epoch
  2. // changes due to too many bias revocations occurring, the biases
  3. // from the previous epochs are all considered invalid.
  4. int bias_epoch() const {
  5. assert(has_bias_pattern(), "should not call this otherwise");
  6. return (mask_bits(value(), epoch_mask_in_place) >> epoch_shift);
  7. }
  8. markOop set_bias_epoch(int epoch) {
  9. assert(has_bias_pattern(), "should not call this otherwise");
  10. assert((epoch & (~epoch_mask)) == 0, "epoch overflow");
  11. return markOop(mask_bits(value(), ~epoch_mask_in_place) | (epoch << epoch_shift));
  12. }
  13. markOop incr_bias_epoch() {
  14. return set_bias_epoch((1 + bias_epoch()) & epoch_mask);
  15. }

是否升级为monitor及返回对应的monitor的指针:


  1. bool has_monitor() const {
  2. return ((value() & monitor_value) != 0);
  3. }
  4. ObjectMonitor* monitor() const {
  5. assert(has_monitor(), "check");
  6. // Use xor instead of &~ to provide one extra tag-bit check.
  7. return (ObjectMonitor*) (value() ^ monitor_value);
  8. }

对象头源码讲解,原来,指向objectMonitor的指针在这里的更多相关文章

  1. Category、load、initialize 源码讲解

    今天深圳天气有暴风雨,没有事情干,趁着周末和平常晚上写一篇关于Category知识的梳理!可能针对平常只会知道些category基本结论知道的人有些帮助,写这篇博客会按照下面的目录结合实例以及Cate ...

  2. Qt5.5.0使用mysql编写小软件源码讲解---顾客信息登记表

    Qt5.5.0使用mysql编写小软件源码讲解---顾客信息登记表 一个个人觉得比较简单小巧的软件. 下面就如何编写如何发布打包来介绍一下吧! 先下载mysql的库文件链接:http://files. ...

  3. 源码讲解 node+mongodb 建站攻略(一期)第二节

    源码讲解 node+mongodb 建站攻略(一期)第二节 上一节,我们完成了模拟数据,这次我们来玩儿真正的数据库,mongodb. 代码http://www.imlwj.com/download/n ...

  4. Vue3中的响应式对象Reactive源码分析

    Vue3中的响应式对象Reactive源码分析 ReactiveEffect.js 中的 trackEffects函数 及 ReactiveEffect类 在Ref随笔中已经介绍,在本文中不做赘述 本 ...

  5. Netty源码解读(二)-服务端源码讲解

    简单Echo案例 注释版代码地址:netty 代码是netty的源码,我添加了自己理解的中文注释. 了解了Netty的线程模型和组件之后,我们先看看如何写一个简单的Echo案例,后续的源码讲解都基于此 ...

  6. Cocos2d-X3.0 刨根问底(五)----- Node类及显示对象列表源码分析

    上一章 我们分析了Cocos2d-x的内存管理,主要解剖了 Ref.PoolManager.AutoreleasePool这三个类,了解了对象是如何自动释放的机制.之前有一个类 Node经常出现在各种 ...

  7. 【源码讲解】Spring事务是如何应用到你的业务场景中的?

    初衷 日常开发中经常用到@Transaction注解,那你知道它是怎么应用到你的业务代码中的吗?本篇文章将从以下两个方面阐述Spring事务实现原理: 解析并加载事务配置:本质上是解析xml文件将标签 ...

  8. laravel5源码讲解整理

    来源:http://yuez.me/laravel-yuan-ma-jie-du/?utm_source=tuicool&utm_medium=referral 目录 入口文件 index.p ...

  9. Servlet基础(一) Servlet简介 关键API介绍及结合源码讲解

    Servlet基础(一) Servlet基础和关键的API介绍 Servlet简介 Java Servlet是和平台无关的服务器端组件,它运行在Servlet容器中. Servlet容器负责Servl ...

随机推荐

  1. 图文并茂详解 NAT 协议!

    什么是 NAT 协议 我们的计算机要想访问互联网上的信息,就需要一个地址,而且这个地址是大家(其他主机)所认可的,是公共的,这个地址也叫做公有 IP 地址. 与之相对的,除了公有 IP 地址外,还有私 ...

  2. python中函数isinstance()用来判断某个实例是否属于某个类

    1 print(isinstance(1,int)) # 运行结果 True 2 # 判断1是否为整数类的实例 3 print(isinstance(1,str)) # 运行结果 False4 # 判 ...

  3. 正确理解jmeter线程组之Ramp-Up

    Ramp-Up表示多少时间内启动线程,比如线程数100,Ramp-Up设置为10,表示10秒内启动100线程,不一定是每秒启动10个线程: 下面我们来做几个测试 线程组设置:100线程,Ramp-Up ...

  4. C#爬虫(04):HtmlAgilityPack解析html文档

    原文链接 https://www.cnblogs.com/springsnow/p/13278283.html 目录 一.爬虫概述 1.使用浏览器获取页面源码 2.HTML解析组件 二.HtmlAgi ...

  5. 《破碎的残阳,我们逆光》连载小说- HashMap剖析

    破碎的残阳,我们逆光[连载小说]- HashMap剖析 "行到水穷处,坐看云起时"        前言: 偶尔翻阅了自己当时高中时代写的日志,发现了几篇自己多年未打开的自写小说草本 ...

  6. 列表视图ListView

    依然是一个listView的Java文件 1 public class ListViewActivity extends Activity { 2 private ListView lv1; 3 @O ...

  7. java 执行shell命令遇到的坑

    正常来说java调用shell命令就是用 String[] cmdAry = new String[]{"/bin/bash","-c",cmd} Runtim ...

  8. QT之HTTP

    概述 QT的HTTP操作都是异步的,内部通过线程实现. 相关类: QNetworkAccessManager [发送网络请求并接收响应] QNetworkReply [服务响应] QNetworkRe ...

  9. java数组复习和内存分配

    Java基础知识复习 1.循环 1.1. for循环 for(int i =1;i<=10;i++){ System.out.println("Hello world"+i) ...

  10. RGBA()函数详解

    RGBA()函数详解 RGBA()函数用于设定颜色和颜色的透明度: