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


Java AtomicInteger.intValue方法代码示例

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


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

示例1: deleteChildren

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
/**
 * Delete TGT's service tickets.
 *
 * @param ticket the ticket
 * @return the count of tickets that were removed including child tickets and zero if the ticket was not deleted
 */
public int deleteChildren(final TicketGrantingTicket ticket) {
    final AtomicInteger count = new AtomicInteger(0);

    // delete service tickets
    final Map<String, Service> services = ticket.getServices();
    if (services != null && !services.isEmpty()) {
        services.keySet().stream().forEach(ticketId -> {
            if (deleteSingleTicket(ticketId)) {
                LOGGER.debug("Removed ticket [{}]", ticketId);
                count.incrementAndGet();
            } else {
                LOGGER.debug("Unable to remove ticket [{}]", ticketId);
            }
        });
    }

    return count.intValue();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:25,代码来源:AbstractTicketRegistry.java

示例2: deleteTicket

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
@Override
public int deleteTicket(final String ticketId) {
    final AtomicInteger count = new AtomicInteger(0);

    if (StringUtils.isBlank(ticketId)) {
        return count.intValue();
    }

    final Ticket ticket = getTicket(ticketId);
    if (ticket == null) {
        return count.intValue();
    }

    if (ticket instanceof TicketGrantingTicket) {
        if (ticket instanceof ProxyGrantingTicket) {
            LOGGER.debug("Removing proxy-granting ticket [{}]", ticketId);
        }

        LOGGER.debug("Removing children of ticket [{}] from the registry.", ticket.getId());
        final TicketGrantingTicket tgt = (TicketGrantingTicket) ticket;
        count.addAndGet(deleteChildren(tgt));

        final Collection<ProxyGrantingTicket> proxyGrantingTickets = tgt.getProxyGrantingTickets();
        proxyGrantingTickets.stream().map(Ticket::getId).forEach(t -> count.addAndGet(this.deleteTicket(t)));
    }
    LOGGER.debug("Removing ticket [{}] from the registry.", ticket);

    if (deleteSingleTicket(ticketId)) {
        count.incrementAndGet();
    }

    return count.intValue();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:34,代码来源:AbstractTicketRegistry.java

示例3: execute

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
private MemgraphCypherScope execute(MemgraphCypherQueryContext ctx, CypherQuery cypherQuery) {
    MemgraphCypherScope scope = MemgraphCypherScope.newSingleItemScope(MemgraphCypherScope.newEmptyItem());
    ImmutableList<CypherClause> clauses = cypherQuery.getClauses();
    AtomicInteger clauseIndex = new AtomicInteger(0);
    for (; clauseIndex.intValue() < clauses.size(); clauseIndex.incrementAndGet()) {
        scope = execute(ctx, clauses, clauseIndex, scope);
    }
    if (clauses.get(clauses.size() - 1) instanceof CypherReturnClause) {
        return scope;
    }
    return MemgraphCypherScope.newEmpty();
}
 
开发者ID:mware-solutions,项目名称:memory-graph,代码行数:13,代码来源:QueryExecutor.java

示例4: getIDF

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
public static double getIDF(final Map<String, List<String>> documents, String term) {
	final double N = documents.size();
	final AtomicInteger termCount = new AtomicInteger(0);

	documents.values().stream().forEach(word -> {
		termCount.addAndGet(word.contains(term) ? 1 : 0);
	});
	if (termCount.intValue() == 0) {
		return 0;
	}
	double idf = Math.log(N / termCount.doubleValue());
	return idf;
}
 
开发者ID:ag-sc,项目名称:JLink,代码行数:14,代码来源:TFIDF.java

示例5: getInstanceNumber

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
private static Integer getInstanceNumber(Object impl,String interfaceId,String method,int port) {
    Class clazz = impl.getClass();
    AtomicInteger num = callbackCountMap.get(clazz);
    if (num == null) {
        num = initNum(clazz);
    }

    if (num.intValue() >= 2000) {
        throw new RuntimeException("[JSF-24301]Callback instance have exceeding 2000 for type:" + clazz+" interfaceId "+interfaceId+" method "+method+" port"+port);
    }

    return num.getAndIncrement();
}
 
开发者ID:tiglabs,项目名称:jsf-sdk,代码行数:14,代码来源:CallbackUtil.java

示例6: getSelectedRow

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
private static int getSelectedRow() throws Exception {
    final AtomicInteger row = new AtomicInteger(-1);
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            row.set(table.getSelectedRow());
        }
    });
    return row.intValue();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:bug7068740.java

示例7: emailTask

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
public void emailTask(final boolean batched)
{
	final Date notBefore = new Date(System.currentTimeMillis() - RETRY_MILLIS);
	final Date processTime = new Date();
	final String attemptId = UUID.randomUUID().toString();
	final ExecutorCompletionService<EmailResult<EmailKey>> completionService = new ExecutorCompletionService<EmailResult<EmailKey>>(
		emailerPool);
	final AtomicInteger emailCounter = new AtomicInteger();
	Multimap<Long, Institution> availableInsts = institutionService.getAvailableMap();
	for( Long schemaId : availableInsts.keySet() )
	{
		schemaDataSourceService.executeWithSchema(schemaId, new Callable<Void>()
		{
			@Override
			public Void call()
			{

				while( processFirstUser(notBefore, processTime, completionService, emailCounter, attemptId,
					batched) )
				{
					Future<EmailResult<EmailKey>> result;
					while( (result = completionService.poll()) != null )
					{
						processResult(result, emailCounter);
					}
				}
				return null;
			}
		});
	}
	try
	{
		while( emailCounter.intValue() > 0 )
		{
			processResult(completionService.take(), emailCounter);
		}
	}
	catch( InterruptedException e )
	{
		LOGGER.error("Error waiting for emails");
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:43,代码来源:NotificationServiceImpl.java

示例8: testConcurrentEvaluation

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
@Test
public void testConcurrentEvaluation() throws InterruptedException, PebbleException {
    PebbleEngine engine = new PebbleEngine.Builder().loader(new StringLoader()).strictVariables(false).build();

    String templateSource = "{{ test.a }}:{{ test.b }}:{{ test.c }}:{{ test.d | upper }}";
    final PebbleTemplate template = engine.getTemplate(templateSource);

    ExecutorService es = Executors.newCachedThreadPool();
    final AtomicInteger totalFailed = new AtomicInteger();

    int numOfConcurrentEvaluations = Math.min(4, Runtime.getRuntime().availableProcessors());
    final Semaphore semaphore = new Semaphore(numOfConcurrentEvaluations);

    for (int i = 0; i < 10000; i++) {
        semaphore.acquire();
        es.submit(new Runnable() {

            @Override
            public void run() {
                try {

                    int a = r.nextInt();
                    int b = r.nextInt();
                    int c = r.nextInt();
                    int d = r.nextInt();

                    TestObject testObject = new TestObject(a, b, c, "test"+d);

                    StringWriter writer = new StringWriter();
                    Map<String, Object> context = new HashMap<>();
                    context.put("test", testObject);
                    template.evaluate(writer, context);

                    String expectedResult = new StringBuilder().append(a).append(":").append(b).append(":")
                            .append(c).append(":").append("TEST").append(d).toString();

                    String actualResult = writer.toString();
                    if (!expectedResult.equals(actualResult)) {
                        System.out.println("Expected: " + expectedResult);
                        System.out.println("Actual: " + actualResult);
                        System.out.println("");
                        totalFailed.incrementAndGet();
                    }

                } catch (IOException | PebbleException e) {
                    e.printStackTrace();
                    totalFailed.incrementAndGet();
                } finally {
                    semaphore.release();
                }
            }
        });
        if (totalFailed.intValue() > 0) {
            break;
        }
    }
    // Wait for them all to complete
    semaphore.acquire(numOfConcurrentEvaluations);
    es.shutdown();
    assertEquals(0, totalFailed.intValue());
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:62,代码来源:ConcurrencyTest.java

示例9: testConcurrentEvaluationWithDifferingLocals

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
/**
 * Issue #40
 *
 * @throws InterruptedException
 * @throws PebbleException
 */
@Test
public void testConcurrentEvaluationWithDifferingLocals() throws InterruptedException, PebbleException {

    final PebbleEngine engine = new PebbleEngine.Builder().loader(new StringLoader()).strictVariables(false).build();
    String templateSource = "{{ 2000.234 | numberformat }}";
    final PebbleTemplate template = engine.getTemplate(templateSource);

    ExecutorService es = Executors.newCachedThreadPool();
    final AtomicInteger totalFailed = new AtomicInteger();

    int numOfConcurrentEvaluations = Math.min(4, Runtime.getRuntime().availableProcessors());
    final Semaphore semaphore = new Semaphore(numOfConcurrentEvaluations);

    final String germanResult = "2.000,234";
    final String canadianResult = "2,000.234";

    for (int i = 0; i < 1000; i++) {
        semaphore.acquire();
        es.submit(new Runnable() {

            @Override
            public void run() {
                try {

                    final boolean isGerman = r.nextBoolean();

                    final Locale locale = isGerman ? Locale.GERMANY : Locale.CANADA;

                    final StringWriter writer = new StringWriter();

                    template.evaluate(writer, locale);

                    final String expectedResult = isGerman ? germanResult : canadianResult;

                    final String actualResult = writer.toString();

                    if (!expectedResult.equals(actualResult)) {
                        System.out.println(String.format("Locale: %s\nExpected: %s\nActual: %s\n",
                                locale.toString(), expectedResult, actualResult));
                        totalFailed.incrementAndGet();
                    }

                } catch (IOException | PebbleException e) {
                    e.printStackTrace();
                    totalFailed.incrementAndGet();
                } finally {
                    semaphore.release();
                }
            }
        });
        if (totalFailed.intValue() > 0) {
            break;
        }
    }
    // Wait for them all to complete
    semaphore.acquire(numOfConcurrentEvaluations);
    es.shutdown();
    assertEquals(0, totalFailed.intValue());
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:66,代码来源:ConcurrencyTest.java

示例10: testConcurrentCacheHitting

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
@Test
public void testConcurrentCacheHitting() throws InterruptedException, PebbleException {
	final PebbleEngine engine = new PebbleEngine.Builder().strictVariables(false).build();
	
	final ExecutorService es = Executors.newCachedThreadPool();
	final AtomicInteger totalFailed = new AtomicInteger();

	int numOfConcurrentThreads = Math.min(4, Runtime.getRuntime().availableProcessors());
	final Semaphore semaphore = new Semaphore(numOfConcurrentThreads);

	for (int i = 0; i < 100000; i++) {
		semaphore.acquire();
		es.submit(new Runnable() {
			@Override
			public void run() {
				try {
					PebbleTemplate template = engine.getTemplate("templates/template.concurrent1.peb");

					int a = r.nextInt();
					int b = r.nextInt();
					int c = r.nextInt();

					TestObject testObject = new TestObject(a, b, c);

					StringWriter writer = new StringWriter();
					Map<String, Object> context = new HashMap<>();
					context.put("test", testObject);
					template.evaluate(writer, context);

					String expectedResult = new StringBuilder().append(a).append(":").append(b).append(":")
							.append(c).toString();

					String actualResult = writer.toString();
					if (!expectedResult.equals(actualResult)) {
						System.out.println("Expected: " + expectedResult);
						System.out.println("Actual: " + actualResult);
						totalFailed.incrementAndGet();
					}

				} catch (IOException | PebbleException e) {
					e.printStackTrace();
					totalFailed.incrementAndGet();
				} finally {
					semaphore.release();
				}
			}
		});
		
		// quick fail
		if (totalFailed.intValue() > 0) {
			break;
		}
	}
	// Wait for them all to complete
	semaphore.acquire(numOfConcurrentThreads);
	es.shutdown();
	assertEquals(0, totalFailed.intValue());
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:59,代码来源:CacheTest.java


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