generation

JAVA并发包(二十四):CyclicBarrier

做~自己de王妃 提交于 2020-02-05 20:54:17
CyclicBarrier中文翻译是循环栏栅,用在并发中,可以理解为它要求指定数量的线程必须 都到达 某个指定位置时才能往下走。为什么叫循环,因为这个栏栅可以多次循环使用,一次放开栏栅后,所有线程都会通过。然后关闭栏栅,后面就可以接着使用。 生活中的例子是,比如一个团队准备去爬山,约定在某个时间地点,要每个成员都到达才会出发。先到达的只能在集合地等待了,只要最后一个成员到达,大家才会出发。代码例子如下: public static void main ( String [ ] args ) throws InterruptedException { CyclicBarrier barrier = new CyclicBarrier ( 2 ) ; Thread t1 = new Thread ( ( ) - > { System . out . println ( "小明到达了集合地" ) ; try { barrier . await ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } System . out . println ( "小明出发爬山" ) ; } ) ; Thread t2 = new Thread ( ( ) - > { System . out . println ( "小张到达了集合地"

Hotspot 垃圾回收之ConcurrentMarkSweepGeneration(一) 源码解析

一笑奈何 提交于 2020-01-30 02:39:00
目录 一、CardGeneration 1、 构造函数 2、expand 3、compute_new_size 二、CMSBitMap 1、构造方法 / allocate 2、mark / par_mark / mark_range / par_mark_range / mark_large_range / par_mark_large_range 3、isMarked / par_isMarked / isUnmarked /isAllClear 4、par_clear / clear_range / par_clear_range / clear_large_range / par_clear_large_range /clear_all 5、getNextMarkedWordAddress / getNextUnmarkedWordAddress / getAndClearMarkedRegion 6、iterate / dirty_range_iterate_clear 三、CMSMarkStack 1、构造方法和allocate 2、pop / push / par_pop / par_push 3、expand 四、ChunkArray 本篇博客讲解表示CMS老年代的ConcurrentMarkSweepGeneration的相关基础类的实现。 一

The G1 Garbage Collector

你离开我真会死。 提交于 2019-12-06 02:11:56
The G1 Garbage Collector The Garbage-First (G1) collector is a server-style garbage collector, targeted for multi-processor machines with large memories. It meets garbage collection (GC) pause time goals with a high probability, while achieving high throughput. The G1 garbage collector is fully supported in Oracle JDK 7 update 4 and later releases. The G1 collector is designed for applications that: Can operate concurrently with applications threads like the CMS collector. Compact(压紧) free space without lengthy(冗长的) GC induced pause times. Need more predictable(可预见的) GC pause durations. Do not

FAQ-GC【官方版】

若如初见. 提交于 2019-12-03 11:41:19
This document describes the behavior of the Java( tm) HotSpot( tm) virtual machine. This behavior is not part of the VM specification, however, and is subject to change in future releases. Moreover the behavior described here is generic behavior and will not apply to the execution of all Java applications. How is the generational collector implemented in HotSpot(tm)? The default collector in HotSpot has two generations: the young generation and the tenured generation. Most allocations are done in the young generation. The young generation is optimized for objects that have a short lifetime

多线程-AQS-CyclicBarrier

心不动则不痛 提交于 2019-11-28 22:46:33
1、CyclicBarrier和CountDownLatch的区别 CountDownLatch是闭锁,只能使用一次,而CyclicBarrier的计数器会重置,可以使用多次,所以CyclicBarrier能够处理更为复杂的场景; CyclicBarrier还提供了一些其他有用的方法,比如getNumberWaiting()方法可以获得CyclicBarrier阻塞的线程数量,isBroken()方法用来了解阻塞的线程是否被中断; PS:有一个线程broken了,整组broken; CyclicBarrier是基于独占锁和阻塞队列实现的,所以并发性能在基因上就有缺陷,应对高并发场景时应谨慎考虑是否使用 CountDownLatch允许一个或多个线程等待一组事件完成而继续,而CyclicBarrier允许一个事件等待一个或多个线程完成而继续。 --------------------- 2、CountDownLatch是使用AQS框架共享锁实现的同步,队列采用的sync同步FIFO队列 CyclicBarrier是使用AQS框架独占锁实现的同步,队列采用了condition阻塞block队列--详见AQS-condition阻塞队列 基于AQS框架的解读,本次正好将AQS的阻塞队列的模式补上。始于栅栏,始于源码 3、源码: package com.ysma.test; import