Using iTunes SDK in multi thread environment
I'd like to use the Windows iTunes COM SDK in a multithread manor.
Ex. create the iTunes COM object in thread A and use it again in thread B.
How it the COM interface for iTunes defined (MULTITHREADED, APPERTMENT THREAD, SINGLETHREADED)
Can I then marshall the interface, between interfaces, without deadlocking my app? (I hate frozen apps, so I use threads as much as possible).
Annoyingly the SDK hasn't been updated in over three years. I've had a casual look via Visual Studio's object inspector to see if I can spot any new methods or properties that could be useful but if they are there then they are hidden well. Media Kind, for example, was introduced in iTunes 9, I think, but can't be read from code.
I don't know what tasks you're hoping to automate, but you might find some of my scripts useful either in their own right or as food for thought.
tt2
Similar Messages
-
Static methods in multi-thread environment.
Sorry for this silly question, but I have no clue...
If you're using classes with static methods in a application server environment, would that imply all threads use that same 'one in the jvm' method and would there be a possibility for performance loss?
Is calling another static method from a static method a good idea in a multi-thread environment, with respect to performance? Somehow I seem to get this java.lang.NoClassDefFoundError. Any ideas? The classes are in the same package. I only get these kind of problems calling static methods from static methods in a multi-thread environmnent. The static methods are pure utility functions and of course do not use class state.
Thanks for your help.Sorry for this question, wasn't thinking straight. I have the answer, won't post question on multiple forums.
-
Multiple Containers read/write access in multi-threaded environment
I'm been reading the Berkeley DB XML Transaction Processing document and have a few questions. I have a multi-threaded environment (not multi-process).
1) In the "Summary and Examples" section, there is an example of several worker threads that perform many writes to a shared container. The one container is passed to all the worker threads, rather them having their own instance of the container. In my application, I could potentially have multiple worker threads acting on the same container, is it better to provide some type of connection pool, so each thread has access to the same container? Is their a problem with each thread creating a new instance of the container and writing to that? Is their pros and cons to each approach?
2) In some specific web applications, they only require read-access and have no intention of writing to the database. If the environment was created with transactions, can these applications open the environment in read-only mode, so as to not suffer the performance penalty of using transactions? Or do they still require transaction support since other threads in other applications might be writing to it. Is it better in this case to
3) Is there any decent connection pooling framework that work well with BDB XML? If transactions are involved, it seems pretty important to always close the container once you are finished with it, which kind of defeats the purpose of pooling. I see a container somewhat analogous to a JDBC transaction, where in connection pooling these transactions remain open, but in BDB XML, it doesn't seem like this is good practice. So clarification here would be appreciated.
Thanks in advance...
ChrisChris,
I'd be careful about trying to draw too many analogies with other sorts of systems. In many ways BDB XML is simpler -- it's just a library, no server process.
An open container is analogous to an open file handle/descriptor in your operating system. It can safely be shared by all threads within a given process. In fact, you should not create more than one -- while that works, it can just be confusing, and a source of errors (for example, if you use a different path to open the container each time, you'll have problems). So by all means share them. Most Java applications just point them in a class that is accessible to all threads.
Other objects that can, and should be shared among threads include:
Environment
XmlManager
XmlQueryExpression
Most others should not. You also mention closing your containers -- there is no reason to close your active container objects until your application needs to shut down. A long-running application will want to use db_checkpoint (or equivalent) to ensure that modified pages are flushed from the transaction log to the database files, but that's about it.
As for concurrency, you obviously need transactions for concurrent write operations. If you want concurrent read access to the same containers, they should use transactions as well. Even if you don't explicitly use transactions, locks are always taken on pages in transactional containers. You cannot open the same container transactionally and not transactionally at the same time -- bad things could happen.
Depending on your performance needs, you could using snapshot concurrency, and see how it works for you. While locking does incur some overhead, it may be acceptable.
You mention creating your own "snapshot" of a container and running read-only on that copy. That's possible to do, but you have to be careful of how you create the snapshot (following hot backup procedures). Also, if you intend to open that "new" container in the same environment or application as the old one, you need to run a program on it to change its internal identification so Berkeley DB won't think it's the same file. That is, you can't just copy a container file to a new name and just open it like it's a new container if it's still in the vicinity of the original. See the -r option for the db_load program.
Now that you are probably really confused, good luck!
Regards,
George -
Using Acrobat SDK for Unix development environment
Hi,
Can it be possible for me to use Acrobat SDK for Unix development environment as a server application??If yes, what are the things that should be installed on the client side to make sure that the client should be able see the produced PDF files?? Kindly help me in this regard..
DeepaklAnubisl wrote:
My customer's solution has several issues generating PDF files and we are looking at the Acrobat SDK as at the instance of the final truth.
I use Interop.Acrobat.dll as a .NET project reference to open and resave PDF documents. I'd like to do all things I mentioned above.
After years and years, I have concluded that if you do serious PDF development, you need a set of libraries. For instance, if you are doing typesetting type of work ("vertical center", "horizontal center", "margin", etc., etc) , there is an excellent library from a guy in Germany (land of Johannes Gutenberg and printing presses)...
... which turned out to be useless in my next project which dealt with AcroForms.
I know exactly what you mean by "the final truth", sometimes I wish Adobe had some sort of official validating tool (like XML does).
Per your comments, I would recommend you to consider this library. It is available in all languages and its output is the same quality as Adobe's or at least in the same league:
http://www.pdftron.com/pdfnet/index.html
If you want to comment further, we must go to a different forum, since we are not supposed to discuss any non-Adobe products here. -
DB_LOCK_DEADLOCK: Using BerkeleyDB Xml in a threaded environment
Hello,
I'm having problems running a Berkeley DB application in a threaded environment. In summary, this is what I'm doing:
I implemented the following class:
ref class MyTestClass
private:
DbEnv* env;
XmlManager* man;
unsigned int ctr;
public:
MyTestClass()
ctr = 0;
env = new DbEnv(0);
env->set_cachesize(0, 64*1024, 1);
env->set_lk_max_lockers(1000);
env->set_lk_max_locks(1000);
env->set_lk_max_objects(1000);
env->open("c:\\temp\\SampleDb",
DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG |
DB_INIT_MPOOL | DB_INIT_TXN | DB_THREAD | DB_PRIVATE, 0);
man = new XmlManager(env, DBXML_ALLOW_AUTO_OPEN);
void MyTestWriter()
while(true)
DbXml::XmlQueryContext *ctx;
DbXml::XmlTransaction *txn;
DbXml::XmlResults *res;
try
ctx = new XmlQueryContext(man->createQueryContext(XmlQueryContext::LiveValues, XmlQueryContext::Lazy));
txn = new XmlTransaction(man->createTransaction());
res = new XmlResults(man->query(*txn, "for $v in collection('test.dbxml')/sessions return insert nodes <A/> into$v", *ctx, DB_RMW));
txn->commit(DB_TXN_SYNC);
catch(XmlException& e)
finally
delete res;
delete txn;
delete ctx;
void DeadlockUnblocker()
while(true)
int ret;
env->lock_detect(0, DB_LOCK_DEFAULT, &ret);
Sleep(5000);
Basically I create a shared MyTestClass object and then spawn 4 threads: 3 of them execute the MyTestWriter method and 1 executes the DeadlockUnblocker method.
What happens is that the 3 threads block even before completing the first write. After 5 seconds the DeadlockUnblocker is executed and 1 thread is unblocked and throws a "DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock" which is trapped by my catch block. However, the other threads are still hanging on the execution and the entire flow of the application is stopped.
Anybody can tell me what I'm doing wrong ??
Thanks
MatteoMatteo,
First, the C++ API works best if you avoid new/delete of Xml* objects. There are relatively few cases where that's necessary. Using scoped objects ensures their destruction.
As for your hang the best tool to use is "db_stat -CA" in the environment directory at the time of the hang to find out what is going on. You'll have to not use DB_PRIVATE in the DbEnv::open() flags for it to work. While a deadlock thread is reasonable if you expect a lot of deadlocks (and concurrent write will do that) it is best to use DbEnv::set_lk_detect() to get immediate detection.
Regards,
George -
Using Facebook SDK in Air HTML environment
Hi,
I am building an AIR application using HTML/JS and I'm trying to work with Facebook Javascript SDK for some simple functionality.
It seem however when running and an AIR environment I am not able to access the FB object.
I have the SDK locally so I know its there but simple FB.init() and FB.login() are non-existent and without errors...
I also tried using the FB AS3 library by incldeding it in <script> tags but this gives me an error
TypeError new window.runtime.com.facebook.graph.Facebook() is not a constructor
Don't know if its because my xml namespace is version 2.0 and not 1.5 (1.5 errors as well but it says some IFilePromise class is not found.
Can the Javascript SDK be used in building Adobe AIR HTML apps?Annoyingly the SDK hasn't been updated in over three years. I've had a casual look via Visual Studio's object inspector to see if I can spot any new methods or properties that could be useful but if they are there then they are hidden well. Media Kind, for example, was introduced in iTunes 9, I think, but can't be read from code.
I don't know what tasks you're hoping to automate, but you might find some of my scripts useful either in their own right or as food for thought.
tt2 -
Memory leak with multi-threaded environment
When starting an environment with the THREADED_MUTEXED
or THREADED_UNMUTEXED mode parameter, the oracle OCCI API
has a memory leak. This can be demonstrated by modifying
the "occidml.cpp" demo program as follows:
Replace line 26:
env = Environment::createEnvironment (Environment::DEFAULT);
with
env = Environment::createEnvironment (Environment::THREADED_MUTEXED);
And replace line 164:
demo->displayAllRows();
with
for (int ii=0; ii<10000; ii++) demo->displayAllRows();
Recompile and run the program, and use "top" to see the
size of the process's used memory continually increase
unbounded.
I am using the Oracle 9.2.0.1.0 database on Linux,
gcc version 2.96.
Is anyone aware of a fix for this problem?Yeah, I did suffer from this.
If possible , you can switch to using OCCI on Oracle 10G client , you will find no memory leak issue anymore.
Another issue is that OCCI is using default connection-blocking implementation , if a DB connection is blocked by accident just like plugging out the network link, you can not get any timeout or connection closed indications. You must implement your own OCCI connection timeout strategy, and you must kill the thread/process you are using. -
Problem about Sparc/solaris10 signal in multi-thread environment
Normally if we send a signal to a process which has several threads, the main thread of this process will handle this signal. But I found in some cases an other thread (not main thread) handled signals even if main thread was alive(mostly main thread was being blocked by __pollsys()).
I want to know why and how this happens.
Thanks.according to man signal.h from a solaris 10 machine ...
Asynchronously generated signals are not directed to
a particular thread but are handled by an arbitrary thread
that meets either of the following conditions:
.... a list of conditions.
So if you have threads that you don't want to take signals, then those threads
must block that signal eg pthread_sigmask()
it is just chance that it usually goes to your "main" thread.
tim -
Static methods in multi-threaded environment
Hi,
I am wondering what happens when several threads try to access the same static method ?
The static method is not synchronized.
Will this create any performance issues ?
The actual scenario is of a J2EE server, where several Session Bean instances try to access a static method in a utility class. Will some session beans have to wait till others are being serviced ?
thnx n regards
s girithanx for replying.
yes. the operations are thread-safe. we do not change the state of any object.
but we make an rmi call to another application thru this static method.
is it ok?
Currently, my session bean has too many private methods - each calling the other application. Due to some quality metrics (a class must be restricted to 700 lines) we have to consider moving these private methods into some Helper class in the form of "public static methods". We have made many utility methods as static, but have some reservations abt doing a similar thing for these methods that call other application.
regards
Shivraman -
Question using Java API in a multi threaded application for MDX queries
Currently I’m building a web application that makes a lot of MDX calls using the Essbase Java API. Each time we run an MDX call we basically run the following code:
IEssbase ess = IEssbase.Home.create(IEssbase.JAPI_VERSION);
IEssDomain dom = ess.signOn(userName, password, false, null, "embedded");
IEssCubeView cv = cv=dom.openCubeView("view", hostName, appName, cubeName);
IEssOpMdxQuery op = cv.createIEssOpMdxQuery();
op.setQuery(false,mdx,false,IEssOpMdxQuery.EEssMemberIdentifierType.NAME);
cv.performOperation(op);
IEssMdDataSet mddata = cv.getMdDataSet();
cv.close();
My questions is, is this the correct way to use the API in multi threaded environment where many users may be hitting the application at the same time? For every request do I need to create a separate IEssbase object and sign on to an IEssDomain? Or can I use a single IEssbase and IEssDomain object for the entire application? If not should I call the IEssDomain.signOff() method after each user’s request has completed? Which of the above objects are thread safe? I’m using Essabae 9.3.1. Any insight would be really appreciated.
Thanks
DavidThanks for the input friend,
I should have mentioned that in my application all
connections to Essbase use the same user name and
password so the filtering isn’t a concern. This is my
first Java application using Essbase has a data
source, I’m used to connecting to various SQL
databases and I always use a connection pool, how is
connection pooling handled in the Essbase java API?I'm not sure what happened to it since I never used it, but there used to be something called the High Availability Services or something that was essentially a connection pool for Essbase JAPI connections, but it required an extra license.
Since you don't care about identity (everyone has full access to everything), you can create your own connection pool, but you'll have to manage your multithreading yourself. Its been this way since the beginning. The C API isn't/wasn't thread-safe either (we tried). -
Memory leaks and multi threading issues in managed client.
In our company we use a lot of Oracle, and after the release of the managed provider we migrated all applications to it. First the things were very impressive : the new client was faster, but after some days applications that uses 100MB with old client goes to 1GB and up. The memory is not the only issue, we use a lot of multi threading, and we experience connection drops and not disposal, after 1 days working one of the application had over 100 sessions on the server. I think there is something wrong with connection pool and multi threading.
Is someone experience same problems.
Yesterday we went back with unmanaged provider. Now things are back to normal.connection drops: did you try to use "Validate Connection=true" parameter in your connection string?
the new client was faster: are you sure with this statement? Even in 64bit environment? I got quite serious performance problems when running application under 64bit process: https://forums.oracle.com/thread/2595323 -
Should Collections be used as return types across threads?
I am wondering when, if ever, it is appropriate to use a Collection as the return type of a method in a multi-threaded environment. Here is our situation:
We have four classes -- Widget, WidgetManager, ClientA, and ClientB. ClientA and ClientB are running in different Threads from each other and from the WidgetManager.
The WidgetManager class that uses a Collection of Widgets internally, and passes the Collection (or an Iterator over it) out as a return value of a method to ClientA, which is running in another thread. ClientA would start to go through it using next() and hasNext() of the Iterator. If the WidgetManager were to get a request from ClientB running in another thread to eliminate a Widget, it would attempt to remove it from the Collection. If ClientA were still looping through the Iterator, this would throw an IllegalStateException b/c the system would be in an inconsistent state. The Iterator given to the ClientA is directly linked to the actual Collection in the WidgetManager (am I right so far?).
In my opinion, in most cases we don't want to synchronize Collections. In the example above, if we had passed out a synchronized Collection, then the WidgetManager couldn't touch the collection while the client was looping through the Iterator. If the client got hung up while looping, then the WidgetManager would be hung up. In this case, I think that it will be better to use the toArray() method of Collection to just dump out the contents to a plain array of Objects. Actually, the WidgetManager could convert this array of Objects to an array of Widgets before passing it out, which would give us the type checking that we don't get with Containers.
The condition where you would want to use a synchronized Collection would be when you actually want the client to do some writing or removing from the Collection. I would expect this to be pretty rare since you usually dont want to give clients access to an interal member (the Collection) of a class.
I think that it is also possible to have read-only Collections, but I think (don't know for sure) that you would still have the same IllegalStateException or synchronization probelms.
Can someone point out the errors in my thinking? Or should you generally only use Collections as internal members in a multi-threaded environment, and use toArray() whenever you want to pass the Collection's data outside of the class?
Thanks for any help.
KeithI haven't tested what happens when you synchronize the
Collection, but I think that you are right. But this
causes the problem that I mentioned in the first post.
That is, what happens if your client STARTS running
through the Iterator, and then stops or gets hung up
for some reason? I assume that you're still blocked.
And it's pretty important to me in this case to not
t be blocked -- WidgetManager is the highest level
class in the system.
I'd like to know if anyone has tested this.
The Iterator implementations used in java.util do not use any synchronization by itself, (which is what you would expect since synchronization over multiple method call will involve much more complications and slower performance) . With iterator, you have to provide the necessary synchronization yourself to maintain thread-safety like this
Iterator itr = get Iterator from collectionInstance ;
synchronized(collectionInstance) {
while(itr.hasNext())
process itr.next() ...
As long as your client code gracefully exits the synchronized block on a stop( or hangup, given that it is detected and handled fast enough), it will not be a problem.
Also, I'd like an example of when you WOULD want to
return a Collection. I'm specifically interested in
when you would want to return one in a multi-threaded
environment, but I'm beginning to wonder when you
would EVER want to return one from a method.
Collections are great for internal uses, but you lose
type-checking and you expose the internals of your
class to modification when you use them as return
types. And if you're returning a read-only
Collection, you might as well return an array, right?Using a read-only proxy will be much faster and space-efficient than toArray(). -
JMS multi thread best practise
Hi,
I would like to code a JMS layer that could be accessed by
a multi thread environment (a web app)
Is there any "Connection-Pool/DAO" equivalent design
pattern for JMS ?
Form what I know, connection are Thread Safe and Sessions
are not ...
PhilippeMany J2EE providers have their own JMS facades which provide pooling - so you could just use your container's JMS wrappers.
Another option, if you are inside a Servlet Engine, is to use Jencks which provides JMS & JDBC connection pooling as well as pooling of threads & message listeners & exception handling when consuming JMS messages.
e.g. here's inbound message consumption...
http://jencks.org/Message+Driven+POJOs
and here's outbound JMS (i.e. pooling when sending JMS messages etc)
http://jencks.org/Outbound+JMS
Jencks is basically a Spring based JCA container so it takes care of all the pooling for you as well as handling message inflow & outflow and can work with XA if you need it as well as local transactions.
James
http://logicblaze.com/ -
Enterprise User and Multi Thread Server
Hi,
We are going to build a system which uses a configuration:
10g2
Enterprise User
Multi Thread Server
Client apps accesses db over JDBC/SSL
Could some please share experience about issues regarding
using Enterprise User and Multi Thread Server ?
Is MTS transparant for Enterprise User authentication ?
Regards,
CezaryIf you build simpserv with -t, and set MIN and MAXDISPATCHTHREADS, you
should have an example of a multithreaded server.
Scott
Johan Philippe wrote:
>
We have been going to the documentation on multi-threading and contexting in servers
on Tuxedo 7.1.
And the impression so far is that apart from the function definitions there is
not much information around.
Didn't even find a simple example of a multi-threaded server in the Bea refs yet.
Does anyone know/have such an example?
And is anyone using multi-contexting in a server, because the limitation that
only server-dispatched
thread get a context puts quite a limitation on its usefullness. -
Oracle Multi-threaded libraries and Forte R3
Hello all,
I heard through the grapevine that it would be possible
to use Oracle 7.3 multi-threaded support with Forte 3.0G.
(thus making Load-Balancing obsolete in this case)
Has anyone given a try at this assumption ?
If yes, on what platform and what versions ?
Thanks,
Vincent Figari
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>Hi,
It is available In R3.0.F.2 also. I tested it this release and it works
very well. But, you need to make a design pattern on it : A Oracle
Session can not be shared between several transactions throught threads.
So You need to manage a pool of DBSessions.
Hope this Helps,
Daniel Nguyen
Freelance Forte Consultant
Vincent R Figari wrote:
>
Hello all,
I heard through the grapevine that it would be possible
to use Oracle 7.3 multi-threaded support with Forte 3.0G.
(thus making Load-Balancing obsolete in this case)
Has anyone given a try at this assumption ?
If yes, on what platform and what versions ?
Thanks,
Vincent Figari
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>-
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
Maybe you are looking for
-
Condition type error in PO.
Hi all, For Import order, i have maintained condition records for a condition type. but that condition type is not displaying in the Conditions tab of PO. when i do analysis, i can see the following against that condition type. "Condition record has
-
When I try to open iPhoto, I get an error message that says it can't open the application because it may be damaged or incomplete.
-
Ok my problem is that I have to order the numbers that are inside the text fields but it keeps showing me : class, interface or enum expected and I just cant find it, I thought it was because of the {} but apparently not so I would really appreciate
-
HT1848 how do i get my apps and music from my ipod to my iphone
how do i get my apps and music from my ipod touch to my iphone?????????
-
Which version OCA,OCP Exam is Better Right now,10g or 11g??
Hello sir, I am Hardik Jethava,I am from India. I want to know which Oracle version OCA and OCP certification is better to pursue according to market trend whether it is better to pursue for 10g or 11g? Please help someone guide me. So,that i can sta