• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Multi-thread and EntityManager on SE application

Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm developing Swing application with JPA 2.0 (EclipseLink 2.0.2)
Since it is Java SE application, I can't use injection and/or JNDI

javax.swing.SwingWorker says:

Time-consuming tasks should not be run on the Event Dispatch Thread. Otherwise the application becomes unresponsive.
Swing components should be accessed on the Event Dispatch Thread only.

So, I use SwingWorker for time-consuming database access.
However, I'm not sure whether objects regarding EntityManager is thread-safe, and there are no "container" to manage them.

1. Can we use EntityManagerFactory object on many threads without explicit synchronize?
2. Can we use EntityManager object (for read-only) on many threads without explicit synchronize?
3. Is it "cheap" to make EntityManager object? (by emf.createEntityManager())
Is it "reasonable" to make EntityManager to invoke only one find operation and close it?
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic