error: package java.util.concurrent does not exist

1,309 views
Skip to first unread message

Akash Kubavat

unread,
Feb 9, 2015, 10:52:06 PM2/9/15
to codenameone...@googlegroups.com
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans
Desktop OS: Win 8
Simulator : --
Device : --

Hello.

I want to handle multiple threads in pool so I am using following coding:
        int corePoolSize = 4;
       
int maxThread = 8;
       
int keepAliveTime = 8000;//in milliseconds
       
       
ExecutorService executor = new ThreadPoolExecutor(corePoolSize, maxThread, keepAliveTime,
               
TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
       
        executor
.execute(new Runnable() {
           
public void run() {
                getTransactionValues();
           
}
       
});

for this code I am importing below statements:
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

As when I save code, it doesn't give me any error.

But when I compile and build it, it gives me these errors:

D:\nz\m4a\akash_test\WorkInProcess\src\userclasses\StateMachine.java:33: error: package java.util.concurrent does not exist
import java.util.concurrent.*;
D
:\nz\m4a\akash_test\WorkInProcess\src\userclasses\StateMachine.java:749: error: cannot find symbol
       
ExecutorService executor = new ThreadPoolExecutor(corePoolSize, maxThread, keepAliveTime,
  symbol
:   class ExecutorService
  location
: class StateMachine
D
:\nz\m4a\akash_test\WorkInProcess\src\userclasses\StateMachine.java:749: error: cannot find symbol
       
ExecutorService executor = new ThreadPoolExecutor(corePoolSize, maxThread, keepAliveTime,
  symbol
:   class ThreadPoolExecutor
  location
: class StateMachine
D
:\nz\m4a\akash_test\WorkInProcess\src\userclasses\StateMachine.java:750: error: cannot find symbol
               
TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
  symbol
:   variable TimeUnit
  location
: class StateMachine
D
:\nz\m4a\akash_test\WorkInProcess\src\userclasses\StateMachine.java:750: error: cannot find symbol
               
TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
  symbol
:   class LinkedBlockingQueue
  location
: class StateMachine
Note: D:\nz\m4a\akash_test\WorkInProcess\src\userclasses\StateMachine.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\nz\m4a\akash_test\WorkInProcess\src\userclasses\StateMachine.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
5 errors


I'm quite amazed why this code / package is generating error ?
Because in Java this concurrent package is from 1.5 and
I tried by setting JDK1.8 and JDK1.7 from Tools -> Java Platform but no luck..
I also tried by re-setting JAVA_HOME and 'path' values swapping from JDK1.8 and JDK1.7 directories but didn't work.

Sorry to post here, I'm not sure is this error related to Codename One or Netbeans,
Apology if it is not related to Codename One.

Thanks.


Shai Almog

unread,
Feb 10, 2015, 1:22:54 AM2/10/15
to codenameone...@googlegroups.com
We don't support the full JDK 1.5 only a subset of that and java.util.concurrent isn't supported at this time.
Its a rather complex package that has many native dependencies.

Akash Kubavat

unread,
Mar 2, 2015, 5:21:09 PM3/2/15
to codenameone...@googlegroups.com
+Shai Almog
Please kindly suggest me the best way to implement a ThreadPool, or something similar to that, which codename one supports.
Thanks,

Shai Almog

unread,
Mar 2, 2015, 11:27:40 PM3/2/15
to codenameone...@googlegroups.com
Thread pools are problematic in terms of overhead since each thread might have a pretty big memory impact so you wouldn't want to cache threads.

What do you need them for? Where would the advantage be over just creating a thread?
Message has been deleted

Akash Kubavat

unread,
Mar 3, 2015, 1:23:09 AM3/3/15
to codenameone...@googlegroups.com
Actually required functionality is where I have to execute 6 different Oracle Queries

So I am planning to call all of them in new thread, a kind of parallel executing.

But to trace whether all of them have been completed or not, 
for that purpose I thought of using the pool which automatically let me know are all of them completed or not..

If I call one by one then it will take more time, specially in a case when internet speed is low.
So I wish to call all of theme in separate thread at one time..

Please can you say how can I implement that in Codename One ?

Shai Almog

unread,
Mar 3, 2015, 10:22:16 AM3/3/15
to codenameone...@googlegroups.com
That would be a mistake.
Network manager works in an asynchronous way anyway and you shouldn't open a thread for it since we already handle all the threading.
Reply all
Reply to author
Forward
0 new messages