Is it possible to run concurrent tasks using web3.js and an Ethereum client?

For example, say we have the following code to iterate through a number of blocks:

var startBlockNumber = 0;
var endBlockNumber = 1000;

for (var i = startBlockNumber; i <= endBlockNumber; i++) {
        var block = web3.eth.getBlock(i, true);
        if (block != null && block.transactions != null) {
          block.transactions.forEach( function(e) {

Is it possible to run the do_something() function concurrently so that the code doesn't wait for each transaction to be processed sequentially?


I want to process each transaction concurrently in a private block chain using a function which may have a high cost in time.

  • Could you elaborate a bit more of what you're trying to achieve? As per the code, you're trying to run the do_something function n times where n=transactions.length in a block. According to the conditions in your code, this function gets executed only if a block has transactions.
    – galahad
    Jul 13 '16 at 14:38
  • I want to run the javascript highlighted above in a browser and execute the function do_something() concurrently on each transaction of each block.
    – Sebi
    Jul 13 '16 at 14:44