当前位置: 首页>>代码示例>>Java>>正文


Java AtomicIntegerArray.length方法代码示例

本文整理汇总了Java中java.util.concurrent.atomic.AtomicIntegerArray.length方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicIntegerArray.length方法的具体用法?Java AtomicIntegerArray.length怎么用?Java AtomicIntegerArray.length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.atomic.AtomicIntegerArray的用法示例。


在下文中一共展示了AtomicIntegerArray.length方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType) throws IOException {
    SerializeWriter out = serializer.getWriter();
    if (object != null) {
        AtomicIntegerArray array = (AtomicIntegerArray) object;
        int len = array.length();
        out.append('[');
        for (int i = 0; i < len; i++) {
            int val = array.get(i);
            if (i != 0) {
                out.write(',');
            }
            out.writeInt(val);
        }
        out.append(']');
    } else if (out.isEnabled(SerializerFeature.WriteNullListAsEmpty)) {
        out.write("[]");
    } else {
        out.writeNull();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:AtomicIntegerArrayCodec.java

示例2: write

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
    SerializeWriter out = serializer.getWriter();

    if (object == null) {
        if (out.isEnabled(SerializerFeature.WriteNullListAsEmpty)) {
            out.write("[]");
        } else {
            out.writeNull();
        }
        return;
    }

    AtomicIntegerArray array = (AtomicIntegerArray) object;
    int len = array.length();
    out.append('[');
    for (int i = 0; i < len; ++i) {
        int val = array.get(i);
        if (i != 0) {
            out.write(',');
        }
        out.writeInt(val);
    }
    out.append(']');
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:25,代码来源:AtomicIntegerArrayCodec.java

示例3: initializeArray

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
private void initializeArray(AtomicIntegerArray arr) {
  for (int i = 0; i < arr.length(); i++) {
    arr.set(i, Integer.valueOf(0));
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:6,代码来源:IntegerStatsDeltaAggregator.java

示例4: main

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {

	final int THREADS=100;
	/**
	 * Atomic array whose elements will be incremented and decremented
	 */
	AtomicIntegerArray vector=new AtomicIntegerArray(1000);
	/*
	 * An incrementer task
	 */
	Incrementer incrementer=new Incrementer(vector);
	/*
	 * A decrementer task
	 */
	Decrementer decrementer=new Decrementer(vector);
	
	/*
	 * Create and execute 100 incrementer and 100 decrementer tasks
	 */
	Thread threadIncrementer[]=new Thread[THREADS];
	Thread threadDecrementer[]=new Thread[THREADS];
	for (int i=0; i<THREADS; i++) {
		threadIncrementer[i]=new Thread(incrementer);
		threadDecrementer[i]=new Thread(decrementer);
		
		threadIncrementer[i].start();
		threadDecrementer[i].start();
	}
	
	/*
	 * Wait for the finalization of all the tasks
	 */
	for (int i=0; i<THREADS; i++) {
		try {
			threadIncrementer[i].join();
			threadDecrementer[i].join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	/*
	 * Write the elements different from 0
	 */
	int errors=0;
	for (int i=0; i<vector.length(); i++) {
		if (vector.get(i)!=0) {
			System.out.println("Vector["+i+"] : "+vector.get(i));
			errors++;
		}
	}
	
	if (errors==0) {
		System.out.printf("No errors found\n");
	}
	
	System.out.println("Main: End of the example");
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Concurrency-Cookbook-Second-Edition,代码行数:62,代码来源:Main.java

示例5: assertAtomicIntegerArray

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
private void assertAtomicIntegerArray(AtomicIntegerArray array) {
  for (int i = 0; i < array.length(); ++i) {
    Assert.assertEquals(1, array.get(i));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:6,代码来源:TestNMClientAsync.java


注:本文中的java.util.concurrent.atomic.AtomicIntegerArray.length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。