• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ThreadPool类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中nxt.util.ThreadPool的典型用法代码示例。如果您正苦于以下问题:Java ThreadPool类的具体用法?Java ThreadPool怎么用?Java ThreadPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: TransactionProcessorImpl

import nxt.util.ThreadPool; //导入依赖的package包/类
private TransactionProcessorImpl() {
    ThreadPool.scheduleThread("ProcessTransactions", processTransactionsThread, 5);
    ThreadPool.scheduleThread("RemoveUnconfirmedTransactions", removeUnconfirmedTransactionsThread, 1);
    if (enableTransactionRebroadcasting) {
        ThreadPool.scheduleThread("RebroadcastTransactions", rebroadcastTransactionsThread, 60);
        ThreadPool.runAfterStart(new Runnable() {
            @Override
            public void run() {
                try (DbIterator<TransactionImpl> oldNonBroadcastedTransactions = getAllUnconfirmedTransactions()) {
                    for (TransactionImpl transaction : oldNonBroadcastedTransactions) {
                        nonBroadcastedTransactions.add(transaction);
                    }
                }
            }
        });
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:18,代码来源:TransactionProcessorImpl.java


示例2: TransactionProcessorImpl

import nxt.util.ThreadPool; //导入依赖的package包/类
private TransactionProcessorImpl() {
    ThreadPool.scheduleThread("ProcessTransactions", processTransactionsThread, 5);
    ThreadPool.scheduleThread("RemoveUnconfirmedTransactions", removeUnconfirmedTransactionsThread, 1);
    ThreadPool.runAfterStart(new Runnable() {
        @Override
        public void run() {
            synchronized (BlockchainImpl.getInstance()) {
                try (DbIterator<UnconfirmedTransaction> oldNonBroadcastedTransactions = getAllUnconfirmedTransactions()) {
                    for (UnconfirmedTransaction unconfirmedTransaction : oldNonBroadcastedTransactions) {
                        if (unconfirmedTransaction.getTransaction().isUnconfirmedDuplicate(unconfirmedDuplicates)) {
                            Logger.logDebugMessage("Skipping duplicate unconfirmed transaction " + unconfirmedTransaction.getTransaction().getJSONObject().toString());
                        } else if (enableTransactionRebroadcasting) {
                            broadcastedTransactions.add(unconfirmedTransaction.getTransaction());
                        }
                    }
                }
            }
        }
    });
    if (enableTransactionRebroadcasting) {
        ThreadPool.scheduleThread("RebroadcastTransactions", rebroadcastTransactionsThread, 60);
    }
}
 
开发者ID:giannisKonst,项目名称:blockchain,代码行数:24,代码来源:TransactionProcessorImpl.java


示例3: shutdown

import nxt.util.ThreadPool; //导入依赖的package包/类
public static void shutdown() {
    if (Init.peerServer != null) {
        try {
            Init.peerServer.stop();
        } catch (Exception e) {
            Logger.logShutdownMessage("Failed to stop peer server", e);
        }
    }
    if (dumpPeersVersion != null) {
        StringBuilder buf = new StringBuilder();
        for (Map.Entry<String,String> entry : announcedAddresses.entrySet()) {
            Peer peer = peers.get(entry.getValue());
            if (peer != null && peer.getState() == Peer.State.CONNECTED && peer.shareAddress() && !peer.isBlacklisted()
                    && peer.getVersion() != null && peer.getVersion().startsWith(dumpPeersVersion)) {
                buf.append("('").append(entry.getKey()).append("'), ");
            }
        }
        Logger.logShutdownMessage(buf.toString());
    }
    ThreadPool.shutdownExecutor(sendingService);
    ThreadPool.shutdownExecutor(peersService);

}
 
开发者ID:giannisKonst,项目名称:blockchain,代码行数:24,代码来源:Peers.java


示例4: shutdown

import nxt.util.ThreadPool; //导入依赖的package包/类
public static void shutdown() {
    if (Init.peerServer != null) {
        try {
            Init.peerServer.stop();
            if (enablePeerUPnP) {
                Connector[] peerConnectors = Init.peerServer.getConnectors();
                for (Connector peerConnector : peerConnectors) {
                    if (peerConnector instanceof ServerConnector)
                        UPnP.deletePort(((ServerConnector)peerConnector).getPort());
                }
            }
        } catch (Exception e) {
            Logger.logShutdownMessage("Failed to stop peer server", e);
        }
    }
    ThreadPool.shutdownExecutor("sendingService", sendingService, 2);
    ThreadPool.shutdownExecutor("peersService", peersService, 5);
}
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:19,代码来源:Peers.java


示例5: TransactionProcessorImpl

import nxt.util.ThreadPool; //导入依赖的package包/类
private TransactionProcessorImpl() {
    ThreadPool.scheduleThread("ProcessTransactions", processTransactionsThread, 5);
    ThreadPool.scheduleThread("RemoveUnconfirmedTransactions", removeUnconfirmedTransactionsThread, 1);
    ThreadPool.runAfterStart(new Runnable() {
        @Override
        public void run() {
            synchronized (BlockchainImpl.getInstance()) {
                try (DbIterator<UnconfirmedTransaction> oldNonBroadcastedTransactions = getAllUnconfirmedTransactions()) {
                    for (UnconfirmedTransaction unconfirmedTransaction : oldNonBroadcastedTransactions) {
                        if (unconfirmedTransaction.getTransaction().isUnconfirmedDuplicate(unconfirmedDuplicates)) {
                            Logger.logErrorMessage("Duplicate unconfirmed transaction " + unconfirmedTransaction.getTransaction().getJSONObject().toString());
                        } else if (enableTransactionRebroadcasting) {
                            broadcastedTransactions.add(unconfirmedTransaction.getTransaction());
                        }
                    }
                }
            }
        }
    });
    if (enableTransactionRebroadcasting) {
        ThreadPool.scheduleThread("RebroadcastTransactions", rebroadcastTransactionsThread, 60);
    }
}
 
开发者ID:Ziftr,项目名称:nxt,代码行数:24,代码来源:TransactionProcessorImpl.java


示例6: BlockchainProcessorImpl

import nxt.util.ThreadPool; //导入依赖的package包/类
private BlockchainProcessorImpl() {

        blockListeners.addListener(new Listener<Block>() {
            @Override
            public void notify(Block block) {
                if (block.getHeight() % 5000 == 0) {
                    Logger.logDebugMessage("processed block " + block.getHeight());
                }
            }
        }, Event.BLOCK_SCANNED);

        ThreadPool.runBeforeStart(new Runnable() {
            @Override
            public void run() {
                addGenesisBlock();
                scan();
            }
        });

        ThreadPool.scheduleThread(getMoreBlocksThread, 1);

    }
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:23,代码来源:BlockchainProcessorImpl.java


示例7: BlockchainProcessorImpl

import nxt.util.ThreadPool; //导入依赖的package包/类
private BlockchainProcessorImpl()
{
  this.blockListeners.addListener(new Listener()
  {
    public void notify(Block paramAnonymousBlock)
    {
      if (paramAnonymousBlock.getHeight() % 5000 == 0) {
        Logger.logDebugMessage("processed block " + paramAnonymousBlock.getHeight());
      }
    }
  }, BlockchainProcessor.Event.BLOCK_SCANNED);
  



  ThreadPool.runBeforeStart(new Runnable()
  {
    public void run()
    {
      BlockchainProcessorImpl.this.addGenesisBlock();
      BlockchainProcessorImpl.this.scan();
    }
  });
  ThreadPool.scheduleThread(this.getMoreBlocksThread, 1);
}
 
开发者ID:stevedoe,项目名称:nxt-client,代码行数:26,代码来源:BlockchainProcessorImpl.java


示例8: shutdown

import nxt.util.ThreadPool; //导入依赖的package包/类
public static void shutdown() {
    Logger.logShutdownMessage("Shutting down...");
    API.shutdown();
    Users.shutdown();
    Peers.shutdown();
    ThreadPool.shutdown();
    Db.shutdown();
    if(BlockchainProcessorImpl.oclVerify) {
        OCLPoC.destroy();
    }
    Logger.logShutdownMessage("Burst server " + VERSION + " stopped.");
    Logger.shutdown();
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:14,代码来源:Nxt.java


示例9: shutdown

import nxt.util.ThreadPool; //导入依赖的package包/类
public static void shutdown() {
    Logger.logShutdownMessage("Shutting down...");
    API.shutdown();
    Users.shutdown();
    Peers.shutdown();
    ThreadPool.shutdown();
    Db.shutdown();
    Logger.logShutdownMessage("Nxt server " + VERSION + " stopped.");
    Logger.shutdown();
}
 
开发者ID:giannisKonst,项目名称:blockchain,代码行数:11,代码来源:Nxt.java


示例10: shutdown

import nxt.util.ThreadPool; //导入依赖的package包/类
public static void shutdown() {
    Logger.logShutdownMessage("Shutting down...");
    API.shutdown();
    Users.shutdown();
    ThreadPool.shutdown();
    Peers.shutdown();
    Db.shutdown();
    Logger.logShutdownMessage("Horizon server " + VERSION + " stopped.");
    Logger.shutdown();
    runtimeMode.shutdown();
}
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:12,代码来源:Nxt.java


示例11: TransactionProcessorImpl

import nxt.util.ThreadPool; //导入依赖的package包/类
private TransactionProcessorImpl() {
    ThreadPool.scheduleThread("ProcessTransactions", processTransactionsThread, 5);
    ThreadPool.scheduleThread("RemoveUnconfirmedTransactions", removeUnconfirmedTransactionsThread, 1);
    ThreadPool.runAfterStart(this::rebroadcastAllUnconfirmedTransactions);
    if (enableTransactionRebroadcasting) {
        ThreadPool.scheduleThread("RebroadcastTransactions", rebroadcastTransactionsThread, 60);
    }
}
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:9,代码来源:TransactionProcessorImpl.java


示例12: shutdown

import nxt.util.ThreadPool; //导入依赖的package包/类
public static void shutdown() {
    API.shutdown();
    Users.shutdown();
    Peers.shutdown();
    TransactionProcessorImpl.getInstance().shutdown();
    ThreadPool.shutdown();
    Db.shutdown();
    Logger.logMessage("Nas server " + VERSION + " stopped.");
}
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:10,代码来源:Nxt.java


示例13: shutdown

import nxt.util.ThreadPool; //导入依赖的package包/类
public static void shutdown() {
    if (Init.peerServer != null) {
        try {
            Init.peerServer.stop();
        } catch (Exception e) {
            Logger.logDebugMessage("Failed to stop peer server", e);
        }
    }
    ThreadPool.shutdownExecutor(sendToPeersService);

}
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:12,代码来源:Peers.java


示例14: shutdown

import nxt.util.ThreadPool; //导入依赖的package包/类
public static void shutdown()
{
  Peers.shutdown();
  ThreadPool.shutdown();
  Db.shutdown();
  Logger.logMessage("Nxt server 0.8.3 stopped.");
}
 
开发者ID:stevedoe,项目名称:nxt-client,代码行数:8,代码来源:Nxt.java


示例15: init

import nxt.util.ThreadPool; //导入依赖的package包/类
public void init() {
    ThreadPool.scheduleThread("GenerateBlocks", generateBlocksTask, 500, TimeUnit.MILLISECONDS);
}
 
开发者ID:giannisKonst,项目名称:blockchain,代码行数:4,代码来源:GeneratorPOW.java


示例16: startForging

import nxt.util.ThreadPool; //导入依赖的package包/类
public void startForging(Block lastBlock) {
    //TODO lastBlock
    ThreadPool.scheduleThread("GenerateBlocks", generateBlocksThread, 500, TimeUnit.MILLISECONDS);
}
 
开发者ID:giannisKonst,项目名称:blockchain,代码行数:5,代码来源:GeneratorNXT.java


示例17: BlockchainProcessorImpl

import nxt.util.ThreadPool; //导入依赖的package包/类
private BlockchainProcessorImpl() {
    final int trimFrequency = Nxt.getIntProperty("nxt.trimFrequency");
    blockListeners.addListener(block -> {
        if (block.getHeight() % 5000 == 0) {
            Logger.logMessage("processed block " + block.getHeight());
        }
        if (trimDerivedTables && block.getHeight() % trimFrequency == 0) {
            doTrimDerivedTables();
        }
    }, Event.BLOCK_SCANNED);

    blockListeners.addListener(block -> {
        if (trimDerivedTables && block.getHeight() % trimFrequency == 0 && !isTrimming) {
            isTrimming = true;
            networkService.submit(() -> {
                trimDerivedTables();
                isTrimming = false;
            });
        }
        if (block.getHeight() % 5000 == 0) {
            Logger.logMessage("received block " + block.getHeight());
            if (!isDownloading || block.getHeight() % 50000 == 0) {
                networkService.submit(Db.db::analyzeTables);
            }
        }
    }, Event.BLOCK_PUSHED);

    blockListeners.addListener(checksumListener, Event.BLOCK_PUSHED);

    blockListeners.addListener(block -> Db.db.analyzeTables(), Event.RESCAN_END);

    ThreadPool.runBeforeStart(() -> {
        alreadyInitialized = true;
        if (addGenesisBlock()) {
            scan(0, false);
        } else if (Nxt.getBooleanProperty("nxt.forceScan")) {
            scan(0, Nxt.getBooleanProperty("nxt.forceValidate"));
        } else {
            boolean rescan;
            boolean validate;
            int height;
            try (Connection con = Db.db.getConnection();
                 Statement stmt = con.createStatement();
                 ResultSet rs = stmt.executeQuery("SELECT * FROM scan")) {
                rs.next();
                rescan = rs.getBoolean("rescan");
                validate = rs.getBoolean("validate");
                height = rs.getInt("height");
            } catch (SQLException e) {
                throw new RuntimeException(e.toString(), e);
            }
            if (rescan) {
                scan(height, validate);
            }
        }
    }, false);

    ThreadPool.scheduleThread("GetMoreBlocks", getMoreBlocksThread, 1);

}
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:61,代码来源:BlockchainProcessorImpl.java


示例18: TransactionProcessorImpl

import nxt.util.ThreadPool; //导入依赖的package包/类
private TransactionProcessorImpl() {
    ThreadPool.scheduleThread(processTransactionsThread, 5);
    ThreadPool.scheduleThread(removeUnconfirmedTransactionsThread, 1);
    ThreadPool.scheduleThread(rebroadcastTransactionsThread, 60);
}
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:6,代码来源:TransactionProcessorImpl.java


示例19: TransactionProcessorImpl

import nxt.util.ThreadPool; //导入依赖的package包/类
private TransactionProcessorImpl()
{
  ThreadPool.scheduleThread(this.processTransactionsThread, 5);
  ThreadPool.scheduleThread(this.removeUnconfirmedTransactionsThread, 1);
  ThreadPool.scheduleThread(this.rebroadcastTransactionsThread, 60);
}
 
开发者ID:stevedoe,项目名称:nxt-client,代码行数:7,代码来源:TransactionProcessorImpl.java


示例20: shutdown

import nxt.util.ThreadPool; //导入依赖的package包/类
public static void shutdown()
{
  ThreadPool.shutdownExecutor(sendToPeersService);
}
 
开发者ID:stevedoe,项目名称:nxt-client,代码行数:5,代码来源:Peers.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StreamInitMessage类代码示例发布时间:2022-05-23
下一篇:
Java Metadata类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap