Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 98 results for
executorservice
- Page 1
Producer Consumer Implementation using ExecutorService
Programming
Software Development
11 Years Ago
by nikolaos
…} import java.util.concurrent.BlockingQueue; import java.util.concurrent.
ExecutorService
; import java.util.concurrent.Executors; import java.util.concurrent.…{ final BlockingQueue<Integer> queue =null;
ExecutorService
executor = Executors.newFixedThreadPool(2); public void addThread(Runnable…
Re: Producer Consumer Implementation using ExecutorService
Programming
Software Development
11 Years Ago
by JamesCherrill
Unless I missed something it looks like your init() methods creates the threads and makes them eligible for execution, but then on lines 12-16 you immediately print the contents of consumerData. At that point there is absolutely no guarantee that the other threads will have executed anything. Creating and starting a thread makes it eligible for …
Re: Producer Consumer Implementation using ExecutorService
Programming
Software Development
11 Years Ago
by nikolaos
Thank you. I tried your suggestion but nothing is printed. For some reason consumerdata is empty. Should i use Future interface and java.util.concurrent.Callable instead of runnable? import java.util.ArrayList; import java.util.Iterator; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException;…
Re: Producer Consumer Implementation using ExecutorService
Programming
Software Development
11 Years Ago
by nikolaos
It was a stupid mistake. In class ExecutorServiceThreadPool i had wrote : final BlockingQueue<Integer> queue =null; instead of : final BlockingQueue<Integer> queue =new ArrayBlockingQueue<Integer>(20); Anyway it was a chance to use CountDownLatch.
Java Concurrency - Safely modify numbers with AtomicInteger
Programming
Software Development
3 Years Ago
by dimitrilc
…class as well. private static void safe(){
ExecutorService
executorService
= Executors.newCachedThreadPool(); for (int i =… //unsafe(); safe(); } private static void unsafe(){
ExecutorService
executorService
= Executors.newCachedThreadPool(); for (int i = 0;…
Java Concurrency - use CyclicBarrier to synchronize tasks across threads
Programming
Software Development
3 Years Ago
by dimitrilc
… asyncBuild(){ final int workerCount = 4; //1
ExecutorService
service = Executors.newFixedThreadPool(workerCount); //2 try{ var… asyncBuild(){ final int workerCount = 4; //1
ExecutorService
service = Executors.newFixedThreadPool(workerCount); //2 try{…
IllegalThreadStateException in applet using SwingWorker?
Programming
Software Development
16 Years Ago
by senthil12345
…<Integer> doNotifyProgressChange; private static
ExecutorService
executorService
= null; public enum StateValue {PENDING,….invokeLater(doDone); } } private static synchronized
ExecutorService
getWorkersExecutorService() { if (
executorService
== null) { //this creates non-daemon…
Make a thread wait for other threads.
Programming
Software Development
14 Years Ago
by Tiny_trixer
…code: Main: [CODE]import java.util.concurrent.
ExecutorService
; import java.util.concurrent.Executors; public class Main… { public static void main(String[] args) {
ExecutorService
thread = Executors.newCachedThreadPool(); RingBuffer share = new RingBuffer();…
Networked chat application between two clients
Programming
Software Development
17 Years Ago
by knight fyre
….ServerSocket; import java.net.Socket; import java.util.concurrent.
ExecutorService
; import java.util.concurrent.Executors; import java.util.concurrent…private ServerSocket server; // server socket to connect with users private
ExecutorService
messageExchange; private Lock messageLock; private Condition userTwoConnect; private Client[] …
Help for extended version of Produce/Consumer
Programming
Software Development
16 Years Ago
by Gman36
…import java.util.concurrent.Executors; //import java.util.concurrent.
ExecutorService
; public class SquirrelMagpieTest { public static void main(String[] …(t, 1); Magpie t1 = new Magpie(t, 1); //
ExecutorService
threadExecutor = Executors.newCachedThreadPool(); //threadExecutor.execute (t1); //threadExecutor.execute …
pass variable by reference to each thread
Programming
Software Development
13 Years Ago
by mrar85
… its effect. code so far:[CODE]import java.util.concurrent.
ExecutorService
; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit… will run a maximum of 100 threads at a time: */
ExecutorService
exec = Executors.newFixedThreadPool(100); /* For all the 100 tasks to…
JAX WS and Database Connection ERROR
Programming
Software Development
13 Years Ago
by avinash_545
…llll package itshop_database_connection; import java.util.concurrent.
ExecutorService
; import java.util.concurrent.Executors; import…> task = new FutureTask (omdb);
ExecutorService
es = Executors.newSingleThreadExecutor (); es.submit (…
activate a radio button from another radio button in java
Programming
Software Development
11 Years Ago
by manel1989
…flux de sortie et derreur du programme C++
ExecutorService
executor = Executors.newFixedThreadPool(2); Callable<String&… flux de sortie et derreur du programme C++
ExecutorService
executor = Executors.newFixedThreadPool(2); Callable<String&…
Strassen Algorithm Multithreading using Callable (Thread Pool)
Programming
8 Years Ago
by subhaac
…package strassen2; import java.util.concurrent.
ExecutorService
; import java.util.concurrent.Executors; …} else strassenMatrixMultiplication(A,B); return C; }
ExecutorService
executor = Executors.newFixedThreadPool (4); public Strassen2() throws…
Finally not executed after try block
Programming
Software Development
7 Years Ago
by saurabh.mehta.33234
… below concurrency code: import java.util.concurrent.
ExecutorService
; import java.util.concurrent.Executors; import java…static void main(final String[] arguments) throws InterruptedException {
ExecutorService
executor = Executors.newSingleThreadExecutor(); try { executor.submit(new Task…
using join() in run() method
Programming
Software Development
13 Years Ago
by _neo_
… terminate it if task takes longer time than timeout. [CODE]
ExecutorService
executor = Executors.newFixedThreadPool(10); MyThread mythr = new MyThread(); executor.execute…
Re: using join() in run() method
Programming
Software Development
13 Years Ago
by _neo_
… static final int NTHREADS = 5; // max active threads count public
ExecutorService
executor; private List<FTask> taskFutures; public TaskManager() { executor…
Scheduling Threads-LinkedBlockingDeques
Programming
Software Development
13 Years Ago
by Baduizm
… the WorkersList code snippet.Should I introduce a Singletone and
ExecutorService
??
Java threaded socket connections timeouts
Programming
Software Development
11 Years Ago
by ktsangop
… pool of threads in my main class : private void StartThreadPool() {
ExecutorService
pool = Executors.newFixedThreadPool(30); List<Future<String>…
Re: Multi Thread Help
Programming
Software Development
16 Years Ago
by Alex Edwards
…Scanner object import java.util.concurrent.*; // for Executors and
ExecutorService
classes public class ChatServer{ private ServerSocket ss; private Socket …private ObjectOutputStream oos; private JTextArea jta; private JTextField jtf; private
ExecutorService
es; public SomeClient(){ setSize(600, 400); setLayout(new BorderLayout());…
Re: Java Threading
Programming
Software Development
17 Years Ago
by Ezzaral
….awt.event.ActionListener; import java.util.concurrent.
ExecutorService
; import java.util.concurrent.Executors; import java….WindowConstants; public class ThreadStopSample extends JFrame implements ActionListener{
ExecutorService
threadPool; Future task; // Constructor public ThreadStopSample(){ //…
Re: Multi Thread Help
Programming
Software Development
16 Years Ago
by Ezzaral
….concurrent.Callable; import java.util.concurrent.
ExecutorService
; import java.util.concurrent.Executors; import…} } private class ProcessThread extends Thread { ServerSocket server;
ExecutorService
requestPool; public ProcessThread(ServerSocket server){ this.server = server;…
Re: Threads - need little help
Programming
Software Development
16 Years Ago
by Alex Edwards
…, however in this case it's even worse because the
ExecutorService
is initialized with 1 reusable Thread which means the other….util.concurrent.*; import java.net.*; public class ConcurrentExample{ public final
ExecutorService
es; private volatile Future currentFuture = null; // if multiple threads share…
Re: How to know when a thread ends.
Programming
Software Development
16 Years Ago
by Ezzaral
…util.concurrent.Callable; import java.util.concurrent.
ExecutorService
; import java.util.concurrent.Executors; import javax…} static class WorkQueue { final int NUM_THREADS = 5;
ExecutorService
execService = Executors.newFixedThreadPool(NUM_THREADS); int totalThingsToDo = 0; int…
Re: How to use FixedThreadPool ?
Programming
Software Development
14 Years Ago
by ~s.o.s~
….com/javase/7/docs/api/java/util/concurrent/
ExecutorService
.html"]Javadocs of the
ExecutorService
interface[/URL] has an example which perfectly…
Re: Thread Pool Executor
Programming
Software Development
13 Years Ago
by emclondon
… came up with. MainClass.java [CODE]import java.util.concurrent.
ExecutorService
; import java.util.concurrent.Executors; public class MainClass { public static… void main(String[] args) {
ExecutorService
exec = Executors.newFixedThreadPool(3); exec.execute(new RunnerClass("Thread…
Re: What code can i use to create a countdown timer in a dialog box?
Programming
Software Development
11 Years Ago
by Xabush
…java.util.concurrent.Executor; import java.util.concurrent.
ExecutorService
; import java.util.concurrent.Executors; import javax.…@Override public void actionPerformed(ActionEvent e) {
ExecutorService
executor = Executors.newSingleThreadExecutor(); executor.execute(new TimerClass());…
Re: How to retrieve status for async call to an REST API performing a task
Programming
Software Development
9 Years Ago
by Kubilay Doğukan
… java.util.concurrent.ExecutionException; import java.util.concurrent.
ExecutorService
; import java.util.concurrent.Executors; import java.util… AsynchronousWorker() { } public static void main(String[] args) {
ExecutorService
es = Executors.newFixedThreadPool(3); final Future future = es.submit(…
Re: Java Threading
Programming
Software Development
17 Years Ago
by Acidburn
… a Thread object since they object was invoked by the
executorService
. And the sempore can be changed but as no effect…
Re: Weird Time-recording problem
Programming
Software Development
16 Years Ago
by Alex Edwards
….util.concurrent .*; import javax.swing.JOptionPane; public class Clock{ private
ExecutorService
es; private long startTime = 0, finishTime = 0, decided; private boolean…
1
2
3
Next
Last
Search
Search
Forums
Forum Index
Hardware/Software
Recommended Topics
Programming
Recommended Topics
Digital Media
Recommended Topics
Community Center
Recommended Topics
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Top Members
Meet People
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
Backlink Auditor
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2025 DaniWeb® LLC