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


Java Duration.dividedBy方法代码示例

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


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

示例1: shutdown

import java.time.Duration; //导入方法依赖的package包/类
public static void shutdown(ExecutorService exec, Duration timeout){
	Duration halfTimeout = timeout.dividedBy(2);
	long halfTimeoutMs = timeout.toMillis();
	logger.info("shutting down {}", exec);
	exec.shutdown();
	try{
		if(!exec.awaitTermination(halfTimeoutMs, TimeUnit.MILLISECONDS)){
			logger.warn("{} did not shut down after {}, interrupting", exec, halfTimeout);
			exec.shutdownNow();
			if(!exec.awaitTermination(halfTimeoutMs, TimeUnit.MILLISECONDS)){
				logger.error("could not shut down {} after {}", exec, timeout);
			}
		}
	}catch(InterruptedException e){
		logger.warn("interrupted while waiting for {} to shut down", exec);
		exec.shutdownNow();
		Thread.currentThread().interrupt();
	}
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:20,代码来源:ExecutorServiceTool.java

示例2: dividedBy

import java.time.Duration; //导入方法依赖的package包/类
@Test(dataProvider="DividedBy")
public void dividedBy(long seconds, int nanos, int divisor, long expectedSeconds, int expectedNanos) {
    Duration t = Duration.ofSeconds(seconds, nanos);
    t = t.dividedBy(divisor);
    assertEquals(t.getSeconds(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanos);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKDuration.java

示例3: getAverageDurationPerIteration

import java.time.Duration; //导入方法依赖的package包/类
public Duration getAverageDurationPerIteration(){
    Duration duration = getDuration();
    return duration.dividedBy(numberOfIterations);
}
 
开发者ID:gessnerfl,项目名称:mysql-jdbc-benchmark,代码行数:5,代码来源:BenchmarkReportData.java

示例4: dividedByZero

import java.time.Duration; //导入方法依赖的package包/类
@Test(dataProvider="DividedBy", expectedExceptions=ArithmeticException.class)
public void dividedByZero(long seconds, int nanos, int divisor, long expectedSeconds, int expectedNanos) {
   Duration t = Duration.ofSeconds(seconds, nanos);
   t.dividedBy(0);
   fail(t + " divided by zero did not throw ArithmeticException");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:TCKDuration.java

示例5: test_dividedByDur_zero

import java.time.Duration; //导入方法依赖的package包/类
@Test(expectedExceptions=ArithmeticException.class)
public void test_dividedByDur_zero() {
   Duration t = Duration.ofSeconds(1, 0);
   t.dividedBy(Duration.ZERO);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:TCKDuration.java

示例6: test_dividedByDur_null

import java.time.Duration; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void test_dividedByDur_null() {
   Duration t = Duration.ofSeconds(1, 0);
   t.dividedBy(null);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:TCKDuration.java

示例7: test_dividedByDur_overflow

import java.time.Duration; //导入方法依赖的package包/类
@Test(expectedExceptions=ArithmeticException.class)
public void test_dividedByDur_overflow() {
   Duration dur1 = Duration.ofSeconds(Long.MAX_VALUE, 0);
   Duration dur2 = Duration.ofNanos(1);
   dur1.dividedBy(dur2);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TCKDuration.java


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