Example usage for java.lang Thread MAX_PRIORITY

List of usage examples for java.lang Thread MAX_PRIORITY

Introduction

In this page you can find the example usage for java.lang Thread MAX_PRIORITY.

Prototype

int MAX_PRIORITY

To view the source code for java.lang Thread MAX_PRIORITY.

Click Source Link

Document

The maximum priority that a thread can have.

Usage

From source file:com.stainlesscode.mediapipeline.audioout.DefaultAudioPlayer.java

public DefaultAudioPlayer(AudioOutput driver, EngineRuntime runtime) {
    this.driver = driver;
    this.engineRuntime = runtime;
    this.audioFrameBuffer = runtime.getAudioFrameBuffer();
    this.bytesPerFrame = driver.getAudioFormat().getFrameSize();
    actualWriterThreadRunnable = new ActualWriterThread();
    actualWriterThread = new Thread(actualWriterThreadRunnable, "Audio Writer Thread");
    actualWriterThread.setDaemon(true);/*from w w w .  j a va 2 s. c o m*/
    actualWriterThread.start();
    actualWriterThread.setPriority(Thread.MAX_PRIORITY);
}

From source file:ThreadViewer.java

public ThreadViewerTableModel() {
    rowCount = 0;/*from w ww  . ja va  2 s . co  m*/
    cellData = new Object[0][0];

    String[] names = { "Priority", "Alive", "Daemon", "Interrupted", "ThreadGroup", "Thread Name" };
    columnName = names;

    Class[] classes = { Integer.class, Boolean.class, Boolean.class, Boolean.class, String.class,
            String.class };
    columnClass = classes;

    columnCount = columnName.length;

    dataLock = new Object();

    noStopRequested = true;
    Runnable r = new Runnable() {
        public void run() {
            try {
                runWork();
            } catch (Exception x) {
                // in case ANY exception slips through
                x.printStackTrace();
            }
        }
    };

    internalThread = new Thread(r, "ThreadViewer");
    internalThread.setPriority(Thread.MAX_PRIORITY - 2);
    internalThread.setDaemon(true);
    internalThread.start();
}

From source file:uk.dsxt.voting.common.cryptoVote.CryptoVoteAcceptorWeb.java

public CryptoVoteAcceptorWeb(String baseUrl, int connectionTimeout, int readTimeout, String receiptsFilePath,
        int threadCount) {
    super();/*  w  ww  . ja v  a  2  s .  c  o  m*/
    acceptVoteUrl = String.format("%s%s", baseUrl, ACCEPT_VOTE_URL_PART);
    httpHelper = new HttpHelper(connectionTimeout, readTimeout);
    receiptsFile = receiptsFilePath == null || receiptsFilePath.isEmpty() ? null : new File(receiptsFilePath);
    senders = new Thread[threadCount];
    for (int i = 0; i < threadCount; i++) {
        senders[i] = new Thread(this::sendVotes);
        senders[i].setPriority(Thread.MAX_PRIORITY);
        senders[i].start();
    }
}

From source file:org.artifactory.cli.common.StreamMasker.java

/**
 * Runs the thread which masks the input
 *
 * @throws RuntimeException Might occur on io error
 *//*from  ww  w.  j a v  a2 s.c om*/
public void run() throws RuntimeException {
    int priorityOriginal = Thread.currentThread().getPriority();
    try {
        Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
        while (!Thread.currentThread().isInterrupted()) {
            out.print(promptOverwrite);
            //confirm that everything was written correctly
            if (out.checkError()) {
                throw new RuntimeException("an I/O problem was detected in out");
            }
            Thread.sleep(1);
        }
    } catch (InterruptedException ie) {
        // resets the interrupted status
        Thread.currentThread().interrupt();
    } finally {
        out.print(setCursorToStart);
        for (int i = 0; i < promptOverwrite.length(); i++) {
            out.print(' ');
        }
        out.print(setCursorToStart);

        Thread.currentThread().setPriority(priorityOriginal);
    }
}

From source file:org.nuxeo.runtime.gf3.GF3Component.java

@Override
public void activate(ComponentContext context) throws Exception {
    Environment env = Environment.getDefault();
    //this is handled in GlassFishServer.createTempDir()
    //        String gf3Root = env.getHome().getAbsolutePath()+"/glassfish";
    //        System.out.println("Using GlassFish home: "+gf3Root);
    //        System.setProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY, gf3Root);
    //        System.setProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY, gf3Root);
    File file = new File(env.getConfig(), "domain.xml");
    if (file.exists()) {
        log.info("Starting GF3 server:" + file.toURI().toURL());
        server = new GlassFishServer(file.toURI().toURL());
    } else {//w w w.j a  v a  2 s . c  om
        log.info("activate : Starting GF3 server with no domain.xml");
        server = new GlassFishServer(8080);
    }
    file = new File(env.getConfig(), "default-web.xml");
    if (file.exists()) {
        log.info("activate : GF3 server using default-web.xml:" + file.toURI().toURL());
        server.setDefaultWebXml(file.toURI().toURL());
    }

    // register RARs - this is a costly operation - do it in a new thread
    log.info("Async. Deploying RARs");
    Thread deployerThread = new Thread(new RarDeployer(), "Deployer");
    deployerThread.setPriority(Thread.MAX_PRIORITY);
    deployerThread.start();
}

From source file:ffx.numerics.fft.Real3DCuda.java

/**
 * <p>/*from  w  w w .j av  a 2s  . c  o  m*/
 * main</p>
 *
 * @param args an array of {@link java.lang.String} objects.
 * @throws java.lang.Exception if any.
 */
public static void main(String[] args) throws Exception {
    int dimNotFinal = 64;
    int reps = 10;
    if (args != null) {
        try {
            dimNotFinal = Integer.parseInt(args[0]);
            if (dimNotFinal < 1) {
                dimNotFinal = 64;
            }
            reps = Integer.parseInt(args[1]);
            if (reps < 1) {
                reps = 5;
            }
        } catch (Exception e) {
        }
    }
    if (dimNotFinal % 2 != 0) {
        dimNotFinal++;
    }
    final int dim = dimNotFinal;
    System.out.println(String.format(
            "Initializing a %d cubed grid.\n" + "The best timing out of %d repititions will be used.", dim,
            reps));

    final int dimCubed = dim * dim * dim;
    final int dimCubed2 = (dim + 2) * dim * dim;

    /**
     * Create an array to save the initial input and result.
     */
    final double orig[] = new double[dimCubed2];
    final double answer[] = new double[dimCubed2];
    final double data[] = new double[dimCubed2];
    final double recip[] = new double[dimCubed];

    final float origf[] = new float[dimCubed2];
    final float dataf[] = new float[dimCubed2];
    final float recipf[] = new float[dimCubed];

    Random randomNumberGenerator = new Random(1);
    int index = 0;
    int index2 = 0;

    /**
     * Row-major order.
     */
    for (int x = 0; x < dim; x++) {
        for (int y = 0; y < dim; y++) {
            for (int z = 0; z < dim; z++) {
                float randomNumber = randomNumberGenerator.nextFloat();
                orig[index] = randomNumber;
                origf[index] = randomNumber;
                index++;

                recip[index2] = 1.0;
                recipf[index2] = 1.0f;
                index2++;
            }
            // Padding
            index += 2;
        }
    }

    Real3D real3D = new Real3D(dim, dim, dim);
    Real3DParallel real3DParallel = new Real3DParallel(dim, dim, dim, new ParallelTeam(),
            IntegerSchedule.fixed());
    Real3DCuda real3DCUDA = new Real3DCuda(dim, dim, dim, dataf, recipf);

    Thread cudaThread = new Thread(real3DCUDA);
    cudaThread.setPriority(Thread.MAX_PRIORITY);
    cudaThread.start();

    double toSeconds = 0.000000001;
    long parTime = Long.MAX_VALUE;
    long seqTime = Long.MAX_VALUE;
    long clTime = Long.MAX_VALUE;

    real3D.setRecip(recip);
    for (int i = 0; i < reps; i++) {
        System.arraycopy(orig, 0, data, 0, dimCubed2);
        long time = System.nanoTime();
        real3D.convolution(data);
        time = (System.nanoTime() - time);
        System.out.println(String.format("%2d Sequential: %8.3f", i + 1, toSeconds * time));
        if (time < seqTime) {
            seqTime = time;
        }
    }
    System.arraycopy(data, 0, answer, 0, dimCubed2);

    real3DParallel.setRecip(recip);
    for (int i = 0; i < reps; i++) {
        System.arraycopy(orig, 0, data, 0, dimCubed2);
        long time = System.nanoTime();
        real3DParallel.convolution(data);
        time = (System.nanoTime() - time);
        System.out.println(String.format("%2d Parallel:   %8.3f", i + 1, toSeconds * time));
        if (time < parTime) {
            parTime = time;
        }
    }
    double maxError = Double.MIN_VALUE;
    double rmse = 0.0;
    index = 0;
    for (int x = 0; x < dim; x++) {
        for (int y = 0; y < dim; y++) {
            for (int z = 0; z < dim; z++) {
                double error = Math.abs((orig[index] - data[index] / dimCubed));
                if (error > maxError) {
                    maxError = error;
                }
                rmse += error * error;
                index++;
            }
            index += 2;
        }
    }
    rmse /= dimCubed;
    rmse = Math.sqrt(rmse);
    logger.info(String.format("Parallel RMSE:   %12.10f, Max: %12.10f", rmse, maxError));

    for (int i = 0; i < reps; i++) {
        System.arraycopy(origf, 0, dataf, 0, dimCubed2);
        long time = System.nanoTime();
        real3DCUDA.convolution(dataf);
        time = (System.nanoTime() - time);
        System.out.println(String.format("%2d CUDA:     %8.3f", i + 1, toSeconds * time));
        if (time < clTime) {
            clTime = time;
        }
    }
    real3DCUDA.free();
    real3DCUDA = null;

    maxError = Double.MIN_VALUE;
    double avg = 0.0;
    rmse = 0.0;
    index = 0;
    for (int x = 0; x < dim; x++) {
        for (int y = 0; y < dim; y++) {
            for (int z = 0; z < dim; z++) {
                if (Float.isNaN(dataf[index])) {
                    logger.info(String.format("Not a number %d %d %d", x, y, z));
                    System.exit(-1);
                }
                double error = Math.abs(origf[index] - dataf[index]);
                avg += error;
                if (error > maxError) {
                    maxError = error;
                }
                rmse += error * error;
                index++;
            }
            index += 2;
        }
    }
    rmse /= dimCubed;
    avg /= dimCubed;
    rmse = Math.sqrt(rmse);
    logger.info(String.format("CUDA RMSE:   %12.10f, Max: %12.10f, Avg: %12.10f", rmse, maxError, avg));

    System.out.println(String.format("Best Sequential Time:  %8.3f", toSeconds * seqTime));
    System.out.println(String.format("Best Parallel Time:    %8.3f", toSeconds * parTime));
    System.out.println(String.format("Best CUDA Time:        %8.3f", toSeconds * clTime));
    System.out.println(String.format("Parallel Speedup: %15.5f", (double) seqTime / parTime));
    System.out.println(String.format("CUDA Speedup:     %15.5f", (double) seqTime / clTime));
}

From source file:org.apache.axis2.clustering.management.DefaultGroupManagementAgent.java

public void applicationMemberAdded(Member member) {
    if (!members.contains(member)) {
        Thread th = new Thread(new MemberAdder(member));
        th.setPriority(Thread.MAX_PRIORITY);
        th.start();/*from   w  ww.  j av a2  s  .  c  o m*/
        try {
            th.join();
        } catch (InterruptedException ignore) {
        }
    }
}

From source file:org.nebulaframework.grid.cluster.manager.services.heartbeat.HeartBeatTracker.java

/**
 * Starts the {@code HeartBeatTracker}.//from  w ww  . ja  v  a  2  s. c  o m
 */
public void start() {
    Thread beatThread = new Thread(this, "HeartBeatTracker-" + nodeId.toString());
    beatThread.setDaemon(true);
    beatThread.setPriority(Thread.MAX_PRIORITY);
    beatThread.start();
    log.debug("[HeartBeat] Started Tracking : " + nodeId);
}

From source file:com.ucmap.dingdinghelper.services.TimingService.java

private void init() {
    String jsonAccountList = (String) SPUtils.getString(Constants.ACCOUNT_LIST, "-1");
    mAccountEntities = JsonUtils.listJson(jsonAccountList, AccountEntity.class);
    if (mAccountEntities == null || mAccountEntities.isEmpty()) {
        return;//from w  w  w . j ava 2 s. co  m
    }
    this.mAccountEntity = mAccountEntities.get(0);

    /*try {
    *//* ? kill ? *//*
                                                                                              Daemon.run(this, TimingService.class, Daemon.INTERVAL_ONE_MINUTE);
                                                                                              } catch (Exception e) {
                                                                                              e.printStackTrace();
                                                                                              }*/

    initCheckInTime(null);
    if (mNotifyThread == null || !mNotifyThread.isAlive()) {
        mNotifyThread = new NotifyThread();
        runing_monitor = true;
        mNotifyThread.setPriority(Thread.MAX_PRIORITY);
        /*?*/
        mNotifyThread.start();
    }
}

From source file:org.apache.hadoop.hbase.ipc.NettyRpcServer.java

public NettyRpcServer(Server server, String name, List<BlockingServiceAndInterface> services,
        InetSocketAddress bindAddress, Configuration conf, RpcScheduler scheduler) throws IOException {
    super(server, name, services, bindAddress, conf, scheduler);
    this.bindAddress = bindAddress;
    EventLoopGroup eventLoopGroup;/*  w w  w .j av a 2s. c om*/
    Class<? extends ServerChannel> channelClass;
    if (server instanceof HRegionServer) {
        NettyEventLoopGroupConfig config = ((HRegionServer) server).getEventLoopGroupConfig();
        eventLoopGroup = config.group();
        channelClass = config.serverChannelClass();
    } else {
        eventLoopGroup = new NioEventLoopGroup(0,
                new DefaultThreadFactory("NettyRpcServer", true, Thread.MAX_PRIORITY));
        channelClass = NioServerSocketChannel.class;
    }
    ServerBootstrap bootstrap = new ServerBootstrap().group(eventLoopGroup).channel(channelClass)
            .childOption(ChannelOption.TCP_NODELAY, tcpNoDelay)
            .childOption(ChannelOption.SO_KEEPALIVE, tcpKeepAlive)
            .childHandler(new ChannelInitializer<Channel>() {

                @Override
                protected void initChannel(Channel ch) throws Exception {
                    ChannelPipeline pipeline = ch.pipeline();
                    FixedLengthFrameDecoder preambleDecoder = new FixedLengthFrameDecoder(6);
                    preambleDecoder.setSingleDecode(true);
                    pipeline.addLast("preambleDecoder", preambleDecoder);
                    pipeline.addLast("preambleHandler", new NettyRpcServerPreambleHandler(NettyRpcServer.this));
                    pipeline.addLast("frameDecoder",
                            new LengthFieldBasedFrameDecoder(maxRequestSize, 0, 4, 0, 4, true));
                    pipeline.addLast("decoder", new NettyRpcServerRequestDecoder(allChannels, metrics));
                    pipeline.addLast("encoder", new NettyRpcServerResponseEncoder(metrics));
                }
            });
    try {
        serverChannel = bootstrap.bind(this.bindAddress).sync().channel();
        LOG.info("NettyRpcServer bind to address=" + serverChannel.localAddress());
    } catch (InterruptedException e) {
        throw new InterruptedIOException(e.getMessage());
    }
    initReconfigurable(conf);
    this.scheduler.init(new RpcSchedulerContext(this));
}