Help coderanch get a
new server
by contributing to the fundraiser

Tim Lim

Greenhorn
+ Follow
since Oct 14, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tim Lim


In your case I believe the casting is appropriate. You might want to check whether you should synchronize on the list while you iterate over it or not (I'm not sure about it, but I believe you should synchronize).

What I had on my mind was this: create a Set to keep IDs of running Example instances (most easily a static Set in the Example class itself, and pay attention to proper synchronization). Then, at the beginning of the Example.run() method, add the instance ID into this set, and in a finally block inside the same method, remove the ID from the set. That way this set will always contain IDs of active Example instances. I don't know whether this is better than your current approach, though.



Hi Martin, thanks for your input, I will consider it. Anyway I have opened a thread pertaining to the ScheduledThreadPoolExecutor class in this thread since this discussion is about casting.
12 years ago
Hi all, I have some problems using SchedulerThreadPoolExecutor.

I wanted to get the Example class implement Runnable. Below is the code snippet


From the API documentation, I can see that there is this getQueue() method that will get BlockingQueue<Runnable>. However, when I try to run through a loop for the BlockingQueue,
I have found that the Runnable contains an instance of ScheduledFutureTask. I could not find a way to get the Example class that I implemented. In addition, I don't see a method that will return a list of running task. So my question are:

1) Is there a way to get Example class that I implemented from the scheduler?
2) Is there a way to keep track of the running task since getQueue() return a list of runnable which are not running?
3) I wanted to implement a code that will stop a task in the event if all 3 attempts of retry failed. So how should I do it?

Your Example instances could register and unregister themselves from the run method; that way you could maintain a list of active instances, and you would not have to cast anything (unregistering would have to be made from a finally block). However, I'm not sure whether this is optimal solution in your situation. Maybe if you posted the code where you intend to cast, we could continue from there?



Hi Martin, what do you mean by register and unregister?

This is the way I do casting.
12 years ago
@Martin Vajsar I want to do cast is because I want to keep track of the ID. Notice that in the Example I have implemented ID. Because I could not find a way to access a thread in the ScheduledThreadPoolExecutor, thus I decided to put an ID in the Runnable so that I can check whether I have any existing ID running.
12 years ago
I will try use instanceof and casting to see if it works.
12 years ago
My apology for the mistake. Runnable is an interface but still I would like to ask if there is a way to return the Example class from the BlockingQueue.
12 years ago
Hi all,

I have this problem and I can't seem to find on the Internet for a solution.
I have this class called Example. Here is the code snippet.



I am using a ScheduledThreadPoolExecutor class. Under that class, there is this method called getQueue.
However the getQueue return a BlockingQueue of Runnable class. Now is the question. Is there a way to cast the Runnable class into Example class?
12 years ago
Hi all, I am looking for a lightweight jar library that allows me to read video and audio meta data.

I wanted to read data like:
1.Video bitrate
2.Video framerate
3.Video format and codec
4.Video size (width X height)
5.Audio channels
6.Audio format
7.Audio bitrate and sampling rate

These are the video and audio formats I will be working with - mp4, mpeg, wmv, avi, wm, midi, wma, mp3, aiff, au and wav

I have google it so far, i cant find any jar files that allow me to do.
So far I have come across these postings:
1. http://stackoverflow.com/questions/7142645/java-library-to-check-video-if-its-1080p-720p-etc
2. http://stackoverflow.com/questions/2168472/media-information-extractor-for-java

However, the solutions provided are not what I am looking for. It will require an installation of the program before you can use the jar files.

So are there any jar files available that allow me to read the video and audio meta data?
12 years ago

Jeff Verdegan wrote:

Tim Lim wrote:@Jeff Verdegan

For 1) I try to use Java to print out the PATH. So far what I do is to use System.getProperty(java.library.path) to print out all the path. So far it is the same as the one in my environment variable



Are there any relative paths in it? Or are they all absolute?
They are absolute path

Did you find the one that contains the DLL in question?
Yup, they did contain the folder with the DLL.

Still the error is the same.

12 years ago
I have some questions regarding about JACOM.

I have downloaded the JACOM binaries 1.6 from this website. I have added the jar files into the CLASSPATH and the directory of the DLL into the PATH. When I tried to use the jar file, it gives this exception



Did I miss out anything?
12 years ago
@Jeff Verdegan

For 1) I try to use Java to print out the PATH. So far what I do is to use System.getProperty(java.library.path) to print out all the path. So far it is the same as the one in my environment variable

For 3) I have tried to add the DLL into the PATH but still it does not work. It still prints out the same error message that the DLL is not found. Regarding to have the Java app to put the same current working directory, can I ask you mean I have to put the app in the same directory as the Paint.Net? If it is so, is there any other way to make it work other than putting it in the same working directory? I actually intended to make it such a way that the java app can be worked regardless of where the app is placed in which directory.
12 years ago
the same command will work fine if I will to run it in command prompt. I dont understand how it does not work in this case. It just complains there is a missing library which is the PDNBulkUpdater.dll but actually the library resides in the Paint.Net/Effects directory
12 years ago
Nope, the result is still the same.
12 years ago
Hi all, I have some problems regarding the use of Process class.

I have an external application that I need to call using Process. The external application that I use is BulkImageProcessor which can only use command line parameters to call the functions of the program.

In my code, I wrote something like this.



The error I got from console is that



So what went wrong?
12 years ago