Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

194
LINES

< > BotCompany Repo | #1011718 // NotifyingBlockingThreadPoolExecutor

JavaX fragment (include)

java.lang.RuntimeException: Unknown token 2: <: 
Warning: session_start(): open(/var/lib/php/sessions/sess_5srtr4jbjjt9ju593gaet5p8cb, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51

Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
{"1011718":"NotifyingBlockingThreadPoolExecutor"} at main.fail(m1008705.java:1589) at main$jsonDecode_Y.fail_base(m1008705.java:14008) at main$jsonDecode_Y.fail(m1008705.java:14006) at main$jsonDecode_Y.parseExpr(m1008705.java:14058) at main$jsonDecode_Y.parse(m1008705.java:14012) at main.jsonDecode(m1008705.java:13990) at main.jsonDecodeMap(m1008705.java:12844) at main.getSnippetTitles(m1008705.java:10820) at main$JavaXHyperlinker.codeToHTML(m1008705.java:6209) at main.html2(m1008705.java:85) at main.html(m1008705.java:67) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:577) at main.invokeMethod(m1008705.java:1601) at main.callOpt_withVarargs(m1008705.java:4387) at main.callOpt(m1008705.java:3326) at main.callHtmlMethod2(m1008705.java:11404) at main$MyHTTPD$1.get(m1008705.java:7337) at main$MyHTTPD$1.get(m1008705.java:1) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:577) at main.invokeMethod(m1008705.java:1601) at main.safeCallF(m1008705.java:642) at main.callF(m1008705.java:611) at main$MyHTTPD.serve(m1008705.java:7373) at main$NanoHTTPD.serve_2(m1008705.java:9572) at main$NanoHTTPD.serve(m1008705.java:9553) at main$NanoHTTPD$HTTPSession.execute(m1008705.java:8453) at main$NanoHTTPD$ClientHandler.run(m1008705.java:7829) at java.base/java.lang.Thread.run(Thread.java:833)

Author comment

From https://github.com/USGS-CIDA/glri-afinch/blob/master/glri-afinch-util/src/main/java/org/java/util/concurrent/NotifyingBlockingThreadPoolExecutor.java

/**
 * This class is a specialized extension of the ThreadPoolExecutor class.
 *
 * Two functionalities had been added to this subclass.
 * 1) The execute method of the ThreadPoolExecutor will block in case the queue is full and only
 *    unblock when the queue is dequeued - that is a task that is currently in the queue is removed
 *    and handled by the ThreadPoolExecutor.
 * 2) Client code can await for the event of all tasks beeing run to conclusion. Client code which
 *    actively chose to wait for this occurrence should call await on the instance of his ThreadPoolExecutor.
 *    This differs from awaitTermination as it does not require any call to shutdown.
 *
 * Code example:
 *
 * NotifyingBlockingThreadPoolExecutor threadPoolExecutor =
 *      new NotifyingBlockingThreadPoolExecutor(5, ,10, 15, TimeUnit.SECONDS);
 *
 * for (int i = 0; i < 5000; i++) {
 *      threadPoolExecutor.execute(...)
 * }
 *
 * try {
 *      threadPoolExecutor.await();
 * } catch (InterruptedException e) {
 *      // Handle error
 * }
 *
 * System.out.println("Done!");
 *
 * The example above shows how 5000 tasks are run within 5 threads. The line with
 * 'System.out.println("Done!");' will not run until such a time when all the tasks given to the
 * thread pool have concluded.
 * their run.
 *
 * This subclass of ThreadPoolExecutor also takes away the max threads capabilities of the
 * ThreadPoolExecutor superclass and internally sets the amount of maximum threads to be the size of
 * the core threads. This is done since threads over the core size and under the max are instantiated
 * only once the queue is full, but the NotifyingBlockingThreadPoolExecutor will block once the queue
 * is full.
 *
 * @author Yaneeve Shekel & Amir Kirsh
 */

	/**
	 * This constructor is used in order to maintain the first functionality specified above.
	 * It does so by using an ArrayBlockingQueue and the BlockThenRunPolicy that is defined in
	 * this class.
	 * This constructor allows to give a timeout for the wait on new task insertion and to react upon such a timeout if occurs.
	 * @param poolSize             is the amount of threads that this pool may have alive at any given time
	 * @param queueSize            is the size of the queue. This number should be at least as the pool size to make sense
	 * 							   (otherwise there are unused threads), thus if the number sent is smaller, the poolSize is used
	 * 							   for the size of the queue. Recommended value is twice the poolSize.
	 * @param keepAliveTime	       is the amount of time after which an inactive thread is terminated
	 * @param keepAliveTimeUnit    is the unit of time to use with the previous parameter
	 * @param maxBlockingTime      is the maximum time to wait on the queue of tasks before calling the BlockingTimeout callback 
	 * @param maxBlockingTimeUnit  is the unit of time to use with the previous parameter 
	 * @param blockingTimeCallback is the callback method to call when a timeout occurs while blocking on getting a new task,
	 * 							   the return value of this Callable is Boolean, indicating whether to keep blocking (true) or stop (false).
	 * 							   In case false is returned from the blockingTimeCallback, this executer will throw a RejectedExecutionException 
	 */

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, ppjhyzlbdabe, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1011718
Snippet name: NotifyingBlockingThreadPoolExecutor
Eternal ID of this version: #1011718/1
Text MD5: ba502c0590c12a3eee15012ab4ac620b
Author: stefan
Category: javax / concurrency
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-03 15:55:34
Source code size: 5247 bytes / 194 lines
Pitched / IR pitched: No / No
Views / Downloads: 1503 / 2503
Referenced in: [show references]