Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 90
Registered: ‎04-03-2012
My Device: 9100
My Carrier: movilnet

Re: Database concurrency Problem

[ Edited ]

well check what i do for wait until start up 

private static void launchBackgroundApp() {

		final ApplicationManager appManager = ApplicationManager
		// sleep until the device is started
		new Thread(new Runnable() {
			public void run() {
				while (appManager.inStartup()) {
					try {
					} catch (Throwable error) {
						// nothing
				final PushAgent app = PushAgent.getInstance();


 and my static shared variable 

 private static UserIdSingleton instance = null;
	 private static String _userId;
	 private static long GUID = 0x63b782ec3bc9c089L;
	 private UserIdSingleton() {
	 public static UserIdSingleton getInstance() {
	      if(instance == null) {
	    	  instance = (UserIdSingleton) RuntimeStore.getRuntimeStore().get(
	      }if ( instance == null ){	    	 
	    	  UserIdSingleton singleton = new UserIdSingleton();
			  RuntimeStore.getRuntimeStore().put(GUID, singleton);
			  instance = singleton;	    	  	    	  	    	  
	      return instance;
	public void setUserId(String _UserId) {
		UserIdSingleton._userId = _UserId;
//		dialogo("userId " + _userId );		

both things are right dont?  , thats way i keep thinking the problems is then i tray to open/acess  DB in  background   app and almost simultaneously.


and i said about my english because i dont explaing the sleep thing was just for test, thx for reply u always reply soon or later Smiley Wink

Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Database concurrency Problem

[ Edited ]

OK, you are trying to be very clever here!  I do this too, when I want the background and foreground processing to share the same application. 


The normal approach is for the background task to create the application.  This would normally be done by main, not a Thread started by main.  There is a KB article that does this 'wait' trick like that I think.  I don't like the 'wait' approach, I prefer the SystemListener approach given in the KB article I referenced. 


I don't think this is actaully related to you problem, but if it was me, I would change your code to use the SystemListener approach.  Or at least don't start the Thread, have the wait loop run in main(). But like I said, I'm not sure this is related. 


Regarding your second code snippet, I can't see how that relates to the first.  Can you explain.  Also it might be useful if you could explain which variable is null. 


Also I would be interested to see the UI start-up code.