java.util.concurrent.atomic.AtomicInteger.intValue()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中java.util.concurrent.atomic.AtomicInteger.intValue()方法的一些代码示例,展示了AtomicInteger.intValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AtomicInteger.intValue()方法的具体详情如下:
包路径:java.util.concurrent.atomic.AtomicInteger
类名称:AtomicInteger
方法名:intValue

AtomicInteger.intValue介绍

[英]Returns the value of this AtomicInteger as an int.
[中]以int形式返回此AtomicInteger的值。

代码示例

代码示例来源:origin: spring-projects/spring-framework

public int getCount(String beanName) {
    AtomicInteger c = count.get(beanName);
    if (c != null) {
      return c.intValue();
    }
    else {
      return 0;
    }
  }
}

代码示例来源:origin: greenrobot/EventBus

public void testSubscriberLegalAbstract() {
  eventBus.register(new AbstractImpl());
  eventBus.post("42");
  assertEquals(1, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testSubscriberLegal() {
  eventBus.register(this);
  eventBus.post("42");
  eventBus.unregister(this);
  assertEquals(1, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testPostStickyTwoEvents() throws InterruptedException {
  eventBus.postSticky("Sticky");
  eventBus.postSticky(new IntTestEvent(7));
  eventBus.register(this);
  assertEquals(2, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testCancel() {
  Subscriber canceler = new Subscriber(1, true);
  eventBus.register(new Subscriber(0, false));
  eventBus.register(canceler);
  eventBus.register(new Subscriber(0, false));
  eventBus.post("42");
  assertEquals(1, eventCount.intValue());
  eventBus.unregister(canceler);
  eventBus.post("42");
  assertEquals(1 + 2, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testCancelWrongEvent() {
  eventBus.register(new SubscriberCancelOtherEvent());
  eventBus.post("42");
  assertEquals(0, eventCount.intValue());
  assertNotNull(failed);
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testPostStickyRegisterNonSticky() throws InterruptedException {
  eventBus.postSticky("Sticky");
  eventBus.register(new NonStickySubscriber());
  assertNull(lastEvent);
  assertEquals(0, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testPostStickyRemoveClass() throws InterruptedException {
  eventBus.postSticky("Sticky");
  eventBus.removeStickyEvent(String.class);
  assertNull(eventBus.getStickyEvent(String.class));
  eventBus.register(this);
  assertNull(lastEvent);
  assertEquals(0, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

public void testSubscriberLegalAbstract() {
  eventBus.register(new AbstractImpl());
  eventBus.post("42");
  assertEquals(1, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testCancelInBetween() {
  eventBus.register(new Subscriber(2, true));
  eventBus.register(new Subscriber(1, false));
  eventBus.register(new Subscriber(3, false));
  eventBus.post("42");
  assertEquals(2, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testPostStickyRemoveEvent() throws InterruptedException {
  eventBus.postSticky("Sticky");
  assertTrue(eventBus.removeStickyEvent("Sticky"));
  assertNull(eventBus.getStickyEvent(String.class));
  eventBus.register(this);
  assertNull(lastEvent);
  assertEquals(0, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testRemoveStickyEventInSubscriber() throws InterruptedException {
  eventBus.register(new RemoveStickySubscriber());
  eventBus.postSticky("Sticky");
  eventBus.register(this);
  assertNull(lastEvent);
  assertEquals(0, eventCount.intValue());
  assertNull(eventBus.getStickyEvent(String.class));
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testSubscriberLegal() {
  eventBus.register(this);
  eventBus.post("42");
  eventBus.unregister(this);
  assertEquals(1, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testPostNonStickyRegisterSticky() throws InterruptedException {
  eventBus.post("NonSticky");
  eventBus.register(this);
  assertNull(lastEvent);
  assertEquals(0, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testPostStickyRemoveAll() throws InterruptedException {
  eventBus.postSticky("Sticky");
  eventBus.postSticky(new IntTestEvent(77));
  eventBus.removeAllStickyEvents();
  assertNull(eventBus.getStickyEvent(String.class));
  assertNull(eventBus.getStickyEvent(IntTestEvent.class));
  eventBus.register(this);
  assertNull(lastEvent);
  assertEquals(0, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testCancel() {
  Subscriber canceler = new Subscriber(1, true);
  eventBus.register(new Subscriber(0, false));
  eventBus.register(canceler);
  eventBus.register(new Subscriber(0, false));
  eventBus.post("42");
  assertEquals(1, eventCount.intValue());
  eventBus.unregister(canceler);
  eventBus.post("42");
  assertEquals(1 + 2, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testPostStickyTwoEvents() throws InterruptedException {
  eventBus.postSticky("Sticky");
  eventBus.postSticky(new IntTestEvent(7));
  eventBus.register(this);
  assertEquals(2, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testRemoveStickyEventInSubscriber() throws InterruptedException {
  eventBus.register(new RemoveStickySubscriber());
  eventBus.postSticky("Sticky");
  eventBus.register(this);
  assertNull(lastEvent);
  assertEquals(0, eventCount.intValue());
  assertNull(eventBus.getStickyEvent(String.class));
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testCancelInBetween() {
  eventBus.register(new Subscriber(2, true));
  eventBus.register(new Subscriber(1, false));
  eventBus.register(new Subscriber(3, false));
  eventBus.post("42");
  assertEquals(2, eventCount.intValue());
}

代码示例来源:origin: greenrobot/EventBus

@Test
public void testPostStickyRemoveAll() throws InterruptedException {
  eventBus.postSticky("Sticky");
  eventBus.postSticky(new IntTestEvent(77));
  eventBus.removeAllStickyEvents();
  assertNull(eventBus.getStickyEvent(String.class));
  assertNull(eventBus.getStickyEvent(IntTestEvent.class));
  eventBus.register(this);
  assertNull(lastEvent);
  assertEquals(0, eventCount.intValue());
}

相关文章