code: public EntityManager getEntityManager(boolean jtaTxExists, boolean unsynchronized)
      {
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
              Tr.entry(tc, "getEntityManager : [" + ivPoolSize + "] tx = " +
                           jtaTxExists + " unsynchronized = " + unsynchronized);
  
          EntityManager em = ivPool.poll();
          if (em != null)
          {
              synchronized (this)
              {
                  --ivPoolSize;
              }
  
              if (jtaTxExists && !unsynchronized)
              {
                  em.joinTransaction();
              }
          }
          else
          {
              // createEntityManager will join transaction if present and is SYNCHRONIZED.
              em = ivAbstractJpaComponent.getJPARuntime().createEntityManagerInstance(ivFactory, ivProperties, unsynchronized);
          }
  
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
              Tr.exit(tc, "getEntityManager : [" + ivPoolSize + "] " + em);
  
          return em;
      }
docs: Returns an EntityManager instance from the pool, or a newly created
  instance if the pool is empty. <p>
  
  If a global JTA transaction is present, the EntityManager will have
  joined that transaction. <p>
  
  @param jtaTxExists
  true if a global jta transaction exists; otherwise false.
  @param unsynchronized
  true if SynchronizationType.UNSYNCHRONIZED is requested, false if not.