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.l2jfree.gameserver.status.Status.java

License:asdf

@Override
public void run() {
    setPriority(Thread.MAX_PRIORITY);
    while (true) {
        try {//from w w w.  j a v  a2 s  .  c  o m
            Socket connection = statusServerSocket.accept();

            new GameStatusThread(connection, _uptime, _statusPw);
            if (isInterrupted()) {
                try {
                    statusServerSocket.close();
                } catch (IOException io) {
                    _log.warn(io.getMessage(), io);
                }
                break;
            }
        } catch (IOException e) {
            if (isInterrupted()) {
                try {
                    statusServerSocket.close();
                } catch (IOException io) {
                    _log.warn(io.getMessage(), io);
                }
                break;
            }
        }
    }
}

From source file:com.l2jfree.gameserver.threadmanager.DeadlockDetector.java

private DeadlockDetector() {
    super("DeadlockDetector");
    setPriority(Thread.MAX_PRIORITY);
    setDaemon(true);/*from  www .j a v  a  2s .  c om*/

    start();

    _log.info("DeadlockDetector: Initialized.");
}

From source file:org.apache.axis2.clustering.DefaultLoadBalanceEventHandler.java

public void applicationMemberAdded(Member member) {
    Thread th = new Thread(new MemberAdder(member));
    th.setPriority(Thread.MAX_PRIORITY);
    th.start();/*from w  ww .j  a v  a  2 s  .co  m*/
}

From source file:org.apache.hadoop.hbase.wal.NettyAsyncFSWALConfigHelper.java

static Pair<EventLoopGroup, Class<? extends Channel>> getEventLoopConfig(Configuration conf) {
    String name = conf.get(EVENT_LOOP_CONFIG);
    if (StringUtils.isBlank(name)) {
        // create new event loop group if config is empty
        return Pair.<EventLoopGroup, Class<? extends Channel>>newPair(
                new NioEventLoopGroup(0, new DefaultThreadFactory("AsyncFSWAL", true, Thread.MAX_PRIORITY)),
                NioSocketChannel.class);
    }/*from w  w  w.ja va  2 s  . com*/
    return EVENT_LOOP_CONFIG_MAP.get(name);
}

From source file:com.garethahealy.jolokiajvmhawkular.core.EmbeddedHawkularMetricsAgent.java

public static void premain(String agentArgs) {
    CustomJvmAgent.premain(agentArgs);//from  ww  w  .  ja  va2 s.co  m

    try {
        LOG.info("About to load BackendManager...");

        Field jolokiaHttpHandlerField = FieldUtils.getDeclaredField(server.getClass(), "jolokiaHttpHandler",
                true);
        JolokiaHttpHandler jolokiaHttpHandler = (JolokiaHttpHandler) jolokiaHttpHandlerField.get(server);

        Field backendManagerField = FieldUtils.getDeclaredField(jolokiaHttpHandler.getClass(), "backendManager",
                true);
        BackendManager backendManager = (BackendManager) backendManagerField.get(jolokiaHttpHandler);

        HawkularClient client = getHawkularClient();
        if (client == null) {
            LOG.error(
                    "HawkularClient is null. Not starting HawkularMetricsService via ScheduledExecutorService.");
        } else {
            BasicThreadFactory factory = new BasicThreadFactory.Builder().namingPattern("hawkular-metrics-%d")
                    .daemon(true).priority(Thread.MAX_PRIORITY).build();

            ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(factory);
            exec.scheduleAtFixedRate(
                    new HawkularMetricsRunnable(new HawkularMetricsService(backendManager, client)), 15, 15,
                    TimeUnit.SECONDS);

            LOG.info("Started HawkularMetricsService via ScheduledExecutorService.");
        }
    } catch (IllegalAccessException e) {
        LOG.error("{}", e);
    }
}

From source file:com.googlecode.concurrentlinkedhashmap.MemoryLeakTest.java

@BeforeMethod
public void beforeMemoryLeakTest() {
    ThreadFactory threadFactory = new ThreadFactoryBuilder().setPriority(Thread.MAX_PRIORITY).setDaemon(true)
            .build();/*from  w w w.  j  a  va 2s.  com*/
    statusExecutor = Executors.newSingleThreadScheduledExecutor(threadFactory);
    statusExecutor.scheduleAtFixedRate(newStatusTask(), statusInterval, statusInterval, SECONDS);
    map = new Builder<Long, Long>().maximumWeightedCapacity(threads).build();
}

From source file:org.polymap.core.runtime.cache.LUCacheManager.java

protected LUCacheManager() {
    // start thread
    memoryCheckerThread = new Thread(new MemoryChecker(), "CacheMemoryChecker");
    memoryCheckerThread.setPriority(Thread.MAX_PRIORITY);
    memoryCheckerThread.start();//w w w  .  j a  va 2  s  .  c  o m

    caches = new MapMaker().initialCapacity(256).weakValues().makeMap();
}

From source file:com.example.gemswin.screancasttest.SenderAsyncTask.java

@Override
protected Void doInBackground(Void... params) {

    Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
    //String portget = MainActivity.portString;

    List<NameValuePair> params1 = new ArrayList<NameValuePair>();
    params1.add(new BasicNameValuePair("class", pref.getclass()));

    String url = "http://176.32.230.250/anshuli.com/ScreenCast/getIPs.php";

    json = jparser.makeHttpRequest(url, "POST", params1);

    try {//w  w  w  . ja va 2s . c o  m
        // Checking for SUCCESS TAG

        //forjson.clear();

        String heading = "";
        String message = "";
        //Toast.makeText(MainActivity.this, (CharSequence) json, 1).show();
        ipArray = new ArrayList<String>();

        JSONArray account = json.getJSONArray("IPs");
        for (int i = 0; i < account.length(); i++) {
            json = account.getJSONObject(i);

            String IpString = json.getString("IP");

            if (!IpString.equals("0.0.0.0"))
                ipArray.add(IpString);
            // forjson.add(Roll+"-"+ NAME);
            //categories_description.add(description);

        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    int port = Integer.parseInt(pref.getSerialNo());

    java.net.Socket socket = null;

    //   ip.add("192.168.15.105");
    //   ip.add("192.168.15.103");
    int len = ipArray.size();
    /*   try {
    for(int i=0;i<ip.size();i++)
    socket[i] = new java.net.Socket(ip.get(i),port);
       //   socket1 = new java.net.Socket("192.168.15.105", port);
     // connect to server
       } catch (IOException e) {
    e.printStackTrace();
       }*/
    dataOut = new DataOutputStream[len];
    try {
        for (int i = 0; i < len; i++) {
            socket = new java.net.Socket(ipArray.get(i), port);
            dataOut[i] = new DataOutputStream(socket.getOutputStream());
        }

        //   dataOut1 = new DataOutputStream(socket1.getOutputStream());
    } catch (IOException e) {
        e.printStackTrace();
    }

    while (!isCancelled()) {

        VideoChunk chunk = null;
        try {
            //Log.d(LOG_TAG, "waiting for data to send");
            chunk = mVideoChunks.takeLast();
            //Log.d(LOG_TAG,"got data. writing to socket");
            int length = chunk.getData().length;
            for (int i = 0; i < ipArray.size(); i++) {

                dataOut[i].writeInt(length);
                dataOut[i].writeInt(chunk.getFlags());
                dataOut[i].writeLong(chunk.getTimeUs());
                dataOut[i].write(chunk.getData());
                dataOut[i].flush();

            }
        } catch (InterruptedException e) {
            e.printStackTrace();
            continue;
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    return null;
}

From source file:com.github.benmanes.caffeine.cache.Stresser.java

public Stresser() {
    ThreadFactory threadFactory = new ThreadFactoryBuilder().setPriority(Thread.MAX_PRIORITY).setDaemon(true)
            .build();//w  w w.j  a v a 2  s.  co  m
    Executors.newSingleThreadScheduledExecutor(threadFactory).scheduleAtFixedRate(this::status, STATUS_INTERVAL,
            STATUS_INTERVAL, SECONDS);
    cache = Caffeine.newBuilder().maximumSize(operation.maxEntries).recordStats().build(key -> key);
    local = (BoundedLocalCache<Integer, Integer>) cache.asMap();
    ints = new Integer[TOTAL_KEYS];
    Arrays.setAll(ints, key -> {
        cache.put(key, key);
        return key;
    });
    cache.cleanUp();
    stopwatch = Stopwatch.createStarted();
    status();
}

From source file:org.pvalsecc.concurrent.Watchdog.java

public void start() {
    if (thread != null) {
        throw new RuntimeException("Watchdog started twice");
    }//from  ww w .j av  a2 s .  c  om
    thread = new Thread(this);

    //noinspection CallToThreadSetPriority
    thread.setPriority(Thread.MAX_PRIORITY);

    thread.start();
}