Sync advice

hi all. bit of a boring one - i'd really appreciate it if anyone has the time....
i'm looking for some pretty general guidance really. i have some data flowing in from an xml source and i am using e a queue (LinkedList, whatever) to accept new objects at one end and for these to be constantly removed and processed (to a database) from the other end. i am a little confused about synchronization and threading, and wondered if anyone could give me an outline of how to get it working.
my current technique is to have a Thread subclass that has a reference to the LinkedList, and uses while(! list.isEmpty())to pop objects off the end. i am synchronizing on the list when my xml reader adds objects to it, and also when this thread takes them off. the problem is that when the reader adds them it doesn't seem to trigger the other end to take them off.
i tried putting the while(! list.isEmpty()) inside a while(true) but the processor goes crazy. i think i need to call wait() and notify, but i'm not sure what on.
can anyone help?!
cheers

Here's something I pulled from a book that might help...
import java.util.*;
* Server adds items to a Queue.  Client takes items off the
* Queue for processing (asynchronously.)
* Taken from Producer/Consumer pattern in "Patterns In Java"
class Queue {
    private List data = new ArrayList();
    synchronized public void enqueue(String s) {
     data.add(s);
     notify();  // use notifyAll() if > 1 Consumer possible
    synchronized public String dequeue() {
     while(data.size() == 0) {
         try {
          wait();
         catch(InterruptedException ignore) {}
     String s = (String)data.get(0);
     data.remove(0);
     return s;
class Consumer implements Runnable {
    private Queue queue;
    Consumer(Queue _queue) { queue = _queue; }
    public void run() {
     String s;
     s = queue.dequeue();
     while(!s.equals("END_OF_INPUT")) {
         System.out.println("consumer processing: " + s);
         s = queue.dequeue();
class Server implements Runnable {
    private Queue queue;
    Server(Queue _queue) { queue = _queue; }
    String[] data = {"coke", "pepsi", "7-up", "orange", "END_OF_INPUT"};
    public void run() {
     for(int i=0; i<data.length; i++) {
         System.out.println("server queuing: " + data);
     queue.enqueue(data[i]);
public class prodcom
public static void main(String[] args)
     Queue q = new Queue();
     // note: starting consumer first
     new Thread(new Consumer(q)).start();
     new Thread(new Server(q)).start();

Similar Messages

  • Multiple device syncing advice needed and appreciated.

    Hey everyone, happy holidays to everyone
    I need some advice from you Apple lovers out there if you can spend some time replying.  Thanks alot in advanced
    My devices and current status
    13" Macbook Pro with 8gig RAM with lion OS - Mosty used for word processing, DJing, low Internet usage now that i have Ipad, photo management, DVD ripping etc etc - i use this as my main device to organise emails and i purchase most apps, music and films on this device too
    Ipad2 - Mostly for media content, web browsing, Youtube, playing games, FB, watching films. I use this device for fun not functionality or work related things
    Iphone 4 - Usual phone usage, I use my phone as my main device for iCal, contacts, checking emails/messages on the move
    2GB time capsule - brand new in the box as yet unused
    Generally speaking i get confused or change my mind frequently about what to sync to which device, i started off using icloud but then things got confusing and i had things real messed up, multiple same contacts, apps on differnet device, differnet music on all 3 devices so now for the moment i think of my Macbook as the main device with both my iphone and ipad backed up to the Macbook. I then back up all of this on a regular 500g external Hard Drive.
    So my questions are as follows
    1. Can and should i use icloud to back up my devices and if so how should i do this effectivly
    2. What syncing procedure would suit me best
    3. How should i integrate Timecapsule to my devices
    Any other suggestions would really be apreciated
    Thanks again

    The second part puzzles me - excuse me (but i honestly don't know) do both units give off a wifi signal of roughly equal 'amounts'?
    Yes. Since both are connected by "Ethernet" each base station is its own wireless network and you have a few options on how best to configure them.
    One of those options is to give both wireless networks the same Network Name (or SSID) so that you can, for example, "walk" a laptop from one to the other and stay connected. This is known as a roaming network.
    If this is something that you don't desire or have a requirement for, then leaving them as two separate wireless networks would work just as well.
    So what i am asking - i guess - is can i increase the distance the wifi signal reaches of the second unit (the time capsule - that is wired to the airport extreme)
    To extend the wireless range of the Time Capsule (TC) you would need another 802.11n AirPort, like the AirPort Express Base Station (AXn). This should get a stronger signal out to the garden. Of course, it would really depend on the distance from the TC to where you would like to place the AXn to get the best results.
    Let me know if you need help configuring the base stations.

  • Iphone music sync advice

    Hello,
    I got an iphone and this was my first time using itunes. My question is while adding new songs to my library and to sync them up , do we need to sync all of the existing ones with newly added or can we just select the newly added ones.
    If i check the newly added songs and sync,my iphone has only the new ones and the old music is gone.
    Pls advice if i am doing this in a wrong way.

    Make a new playlist, and fill it with whatever tunes you want from your library by dragging the tunes there. With your phone connected, choose the Music tab, check Sync Music, and choose "Selected Playlists" and pick the playlist you created. Now sync.
    If you have "only sync checked items" selected on the main Summary tab, it will only sync those that are checked in the playlist. So you might want to just leave all your music checked, but only drag those you want synced to the playlist.
    Once you get the hang of it, it really is a simple way to keep what you want on the iphone. You can sync more than one playlist if you like, and they'll all show up on the phone. But that way, if you have more than 8 GB of music, you couldn't sync it all anyway, so you'd have to have a subset of what you want on the phone, that is, a playlist.

  • Sync advice please...

    Scenario...
    Home..Mac Mini used for syncing 2 users...me and wife. Acer laptop 2 users...me and wife generally used for travelling to 2nd home in Spain (no children).
    Wife has iPhone + iPod....I have iPod.
    We are now going for extended stay, about 6 months and want to sync her iPhone + iPod via iTunes for Windows (Acer laptop). Now I have accessed iTunes Windows today and authorised it so her phone shows up. All fine there.
    Now what I want to do is have all her Apps, Music etc show up but for some reason the App list that would be on left column is blank but the view of apps on her phone show up but in a sort of greyed out window.
    Now if I get the the point where I wasn't to 'sync' a warning window pops up and say all items on Phone will be deleted to match iTunes.
    If I connect her phone to iTunes on Mini and log in to iTunes, the App section right hand column shows all her installed Apps and nothing is greyed out. I can happily hit the sync button and it syncs.
    The same with Music on Mac Mini....on her phone she has her music and when connected to Mini all is visible but in Windows iTunes it says the same thing.
    So how do use iTunes Windows to achieve the exact same as iTunes Mac. Now I could go out and but a new Macbook Pro but to be truthful I would rather spend 2.5k on something else and wait till 2013 when there may be a completely different model line up. (I had a AlyPB G4 but it has bitten the dust.)
    We have iCloud but of course this doesn't sync App or Music.
    So what am I doing wrong?
    Thanks

    You either need to migrate the library from the Mac Mini to the Acer Laptop, or coax the iPhone into treating the Acer's library as home. Or possibly a bit of both...
    See   Recovering your iTunes library from your iPod or iOS device.
    tt2

  • 3 CAMERAS SYNC ADVICE

    I am trying to edit an interview that had 3 seperate cameras. I have each shot on a seperate track on the time line. I plan on using the sound from only one of the cams. I have all 3 shots lined up from a hand clap at the beginning. The duration is about 50 minutes. All 3 are a bit off by the end of the footage.
    Any ideas that might help me do this the easiest way with the tools I am using?
    I am planning on using one sequence to help me stay organized with my fooage and use a second sequence to actually build my project.
    Thanks in advance!
    Frank
    Message was edited by: MalibuFrank

    Hello Frank,
    First, is the audio for each track in perfect sync with its own video track? At the start, and all the way to the end? Or does the audio gradually drift out of sync, and if so by how much is it off at the end? If it doesn't drift gradually, is there a point in the timeline where it first goes out of sync?
    Assuming each audio track is sync'd with its own video track, and you have lined up all 3 tracks to match perfectly at t=0, have you tested each audio track across the whole timeline, one by one (by muting tracks 2&3 to test track 1; then by muting tracks 1& 3 to test track 2, etc), to see if at least one of the audio tracks remains in sync all the way to the end? Same questions as above - does it drift out of sync, or is there a place in the timeline where it goes out of sync?

  • Need i-Phone sync advice.

    Can I have sync my i-phone to two different computers, at work and home?

    I believe Apple's position is that you can only sync an iPhone to one computer. In practice, however, you can sync to more than one computer *if you're syncing different types of info.* For example, my iPhone syncs to my iMac for iTunes media and to my work PC for calendars and contacts.
    If you try to sync iTunes media from the second computer, it deletes all iTunes media from the first computer and replaces it with the media from PC #2 (i.e., you can't use an iPhone to move iTunes media from one computer to the next). A few people have reported success in keeping calendars & contacts in sync between two computers and the iPhone, but that did not work for me.
    Just to give you an idea on my sync frequency: I average once a day sync'ing with the work PC (although it can be several times a day) and a couple times a week with the iMac.
    HTH
    QS

  • New iCloud Notes Sync: Advice Needed

    Signing on to my iCloud account this morning I now have Notes and Reminders files, as I expected to find them. Looking first at the Reminders file, I found all my Reminders, completed and open, over 350 of them. Everything looks great and I really like the ability to amend them on my iMac. Great!
    I opened the Notes file hoping to find all the (many) notes I have on my iPhone and iPad. Nope, not there! Upon further investigation, it seems I created those notes on the two devices using my Gmail account. I did not realize I was doing that, but now on the iPhone under Accounts I find three listed: Gmail, iCloud and my dot me account. The iCloud account shows zero notes, the Gmail has a great many and the dot me account has three.
    My question for the group is, how can I move ALL my notes over to the iCloud account and going forward be assured I am creating new notes using the iCloud account so I can utilize the versatility of this new service? (I can tell you that my notes have been synchronized between the iPhone and iPad. Thus, I assumed I had been using iCloud all along and iCloud Notes has been enabled on both mobile devices all along.)

    Okay, I have tested the system since updating my iPhone and iPad to IOS 6. As mentioned above, I set the default on both devices for future Notes to be iCloud. I created a note on my iPhone and it did show up on the iPad (completely expected that as that has been happening all along) AND it showed up online via my iMac by going to my iCloud account.
    So, this question remains and is now refined to be -
    How can I transfer all Notes created via other platforms (Gmail or my Dot Me account) to the Cloud?

  • Find sync password

    Main Laptop harddrive died so have all bookmarks etc synced with weave on a n900 maemo 5 but can't remember the passphrase sync advice says look at the stored passwords in Preferences but cannot find them on the N900

    Here are instructions for retrieving your passphrase. Sory, they are rather long.
    1. Open Fennec. Type "about:config" in the address bar and press return.
    2. In the search box at the top of the about:config page, type "console".
    3. Tap the line that says "browser.console.showInPanel" and then tap the button that says "false". It will change to say "true".
    4. Shut down Fennec (using the "close" button in the top right) and then start it again.
    5. Drag the Fennec window so you can see the right-hand toolbar, and press the button at the bottom right to open the preference panel.
    6. Tap the button near the lower left with a "bug" icon. A screen titled "Error Console" will appear.
    7. Press the button that says "Clear".
    8. In the box next to the word "Code:" type this all on one line (the punctuation and capitalization must match):
    Components.utils.import("resource://services-sync/service.js"); Weave.Services.passphrase
    8. When you press return, your passphrase will appear. If you change "passphrase" to "password" and press return again, then your password will appear.
    Sorry again for the long and complicated procedure. Let me know if you need any help, or stop by the #mobile channel on http://irc.mozilla.org/ if you need more assistance.

  • AppleTV and ethernet

    Here goes-
    If you read this article on syncing advice from Apple:
    http://docs.info.apple.com/article.html?artnum=305254
    It seems to me that a permanent ethernet connection from my AEBS to my AppleTV (when it arrives) is the best solution.
    My question is- what kind of ethernet cable do I need for this, I've looked on Amazon, will this one be ok:
    http://www.amazon.co.uk/Cat5e-RJ45-Ethernet-Network-Cable/dp/B000IAHNKC/ref=pdsbs_ce4/203-2958914-6953559?ie=UTF8&qid=1174931801&sr=8-20
    Any help would be appreciated

    I can tell you that Airport Extreme "n" > Ethernet >
    Express "g".
    The speed of any 802.11 network depends greatly on the distances between wireless devices, the type & size of any interfering objects between them, & the presence & strength of interfering signals in the area. Additionally, the wireless bandwidth is shared by all devices using it, while in switched Ethernet networks each device with a direct connection to the switch has its own full bandwidth connection.
    IOW, your ranking may not apply in other locations, or even your own, should other wireless networks or interfering sources appear in it.

  • Hi, I need help and advice. Basically me and my ex partner both had iphones and synced it with the same computer under the same ID. We split i have a new laptop and now it keeps asking for the old ID or it'll erase my apps bought on theold account.

    Hi, I need help and advice. Basically me and my ex partner both had iphones and synced it with the same computer under the same ID. We split up and now im trying to get all my apps and info onto my new laptop with a new account but it keeps asking me for the old apple ID which she is still using and she changed the password. i tried backing it up but still nohing. When i try to back up purchased items being apps etc its keeps asking for the old one. help

    See Recover your iTunes library from your iPod or iOS device. But you'll still need the password.
    Once you have the computer authorized to use the account she could change the password again to stop you buying apps on her card (assuming it's not on yours!). It would lock you out of upgrading them too but they should work unless she uses the deathorize all feature.
    It depends on how amicable the split is...
    tt2

  • I updated to iTunes 12 and didn't like it. Followed advice to revert to 11.1. Now my iphone won't sync and error message says I need iTunes 11.2 or higher. Apple Download choices didn't have anything between 11.1.5 and 12. What can I do?

    I updated to iTunes 12 and didn't like it. Followed advice to revert to 11.1. Now my iPhone 5 won't sync and error message says I need iTunes 11.2 or higher. Apple Download choices didn't have anything between 11.1.5 and 12. What can I do? Using iTunes 12 is not an option. Many features I used for audiobooks have disappeared.

    The version immediately prior to 12 was 11.4.0.18. Here are direct download links from Apple's servers:
    iTunes 11.4.0.18 for Windows (32-bit) - iTunesSetup.exe (2014-09-09)
    iTunes 11.4.0.18 for Windows (64-bit) - iTunes64Setup.exe (2014-09-09)
    tt2

  • My 3 kids have itouches, i have an iphone 4 and an ipad.  i just lost all my notes on my ipad and iphone.  i synced both to my mac but i can't find them anywhere...advice?

    i synced both to my mac to see if they would come back and they do not.  i looked at other forums and most of the people that had success getting them back used gmail.  I do not.  My email is verizon.  The only notes that were on there before the sync were 2 short notes that look like they could have been from one of my kids (although they all deny they belong to them of course).  now after the sync there are 4 notes all from december or this past sunday but the other 20 or so notes are nowhere to be seen.  I suppose part of the problem could be that i really don't understand the icloud.  I am really struggling to figure out how to use it.  the other day i synced my ipad (because i usually enter all my calendar dates on there and they were not syncing to my iphone via the icloud and now i have duplicates of a bunch of calendar events.  i am getting so frustrated.  Any advice welcome.  Thanks. 

    Thanks for the reply.
    True by my description it would seem I sent them nowhere, but ten minutes later after turning on and off Contacts in the Cloud I got most of them.
    I have the most recent one I added about 4 days ago but I'm missing some here and there.
    I logged in with my Apple ID and it's the only one I've ever used.
    Still a little weird.
    I have synced my contacts with iTunes but not very recently.
    I now have learned to do it often!
    As far as I can tell there's no rhyme or reason for my missing contacts.
    It's odd I would have most, but not all. So I must have uploaded something since I have some of my recent adds that were after my last sync with iTunes.

  • Advice on how to access photos on an iPad that were synced from a now failed laptop? The question stems from a need to return my current iPad having just taken delivery of a new unit. Thanks

    I am after some advice on how to access photos on an iPad that were synced from a now failed laptop? The question stems from a need to return my current iPad having just taken delivery of a new unit. Thanks

    If you have a dropbox account, there's a free app (probably more) that syncs photos to your dropbox account - picbox. 
    There's also PhotoSync that syncs photos to/from a number of different services and devices.

  • ITunes 11.1.4 totally snarfed my iTunes and ability to properly sync the associated iPhone. Any advice?

    Computer in question is a 13" mid 2007 White MacBook running OS X 10.6 (Snow Leopard). I do not have core specs in front of me but I can look them up later if needed. Phone in question is an iPhone 4s iOS is most current viable version for this generation, 7.0.4 (or so I though, but we will get to that)
    Background on how this started:
    This morning my daughter wanted to sync her iPhone to add new songs to it. When she logged into iTunes a pop-up appeared saying 11.1.4 was available to install. Performed the install and then plugged the phone in and things went belly up. A warning box popped up saying that the phone needed to be reset to factor default and... I could not read the rest because the pop-up then disappeared. The computer then force "ejected" the phone. I pulled the USB out and then plugged it back in. More trouble.
    Here are the issues I had in the half hour I was dealing with it.
    -iTunes starts acting like it is synching with the phone but the button on the upper right that usually contains the name of the phone now reads: "You need to turn on synchronization in iSync before you can sync contacts and calendars."
    Okkkkkaaaaay... And where is iSync so I can do this?? Quick Google search tells me that iSync is an app that is used for phones that are not iPhones to sync them to iTunes. Question: Why do I need iSync if this is an iPhone we are synching??
    Next, clicking on the 'name' button we get our standard 'Summary' screen, except it is not so standard anymore... I have screen shots that I can post up if that would make things easier but for now:
         -Next to the blue 'Done' button it reads "The iPhone "^FILENAME" cannot be synced because it cannot be read from or written to" Question 1: Why is iTunes no longer recognizing this iPhone for read from and write to? Question 2: iTunes recognizes the phone's name in the iPhone 4s pane, why is it calling it unrecognizable up here?
         -In the iPhone 4s pane it says the iOS is 7.0.4 but below that it says "A newer version of the iPhone software is available (version 2/25/14). To update your iPhone with the latest software, click Update."  The 'Check for Update' button also runs out the right side of this pane. Questioin: Why is iTunes seeing a future update and telling me to get it?
         -In the Backups pane where you can select either 'iCloud' or 'This computer' the phone is listed as being called "%1$S"; e.g., 'Photos synced to "%1$S" from other photo libraries will be...'
    After six attempts I was able to get the new songs on to her phone. I ejected it and sent my daughter on her way.
    Then I looked at the iTunes window itself now that the phone was ejected and see that it has been altered as well. If you have 'Music' selected from the drop down then across the top you have various sort options. After the 11.1.4 update these options are:
                                                                               Artist   Genre   Videos   Playlist   Radio   List 
    Except when you click on each of these the options are obviously not what they say they are.
         -Clicking Artist brings up a list that is (was) Songs
         -Clicking Genre brings up a list that is (was) Albums
         -Clicking Videos brings up a list that is (was) Artists
         -Clicking Playlists brings up a list that is (was) I think Genius
         -Clicking List brings up a list that is (was) Playlists
    The only thing that does not seem to be screwed up is the Radio option as that brings up the Radio option.
    At this point we had to leave for school so I was not able to search for any further issues but I will not be surprised if there are more.
    I have tried a number of searches over the course of the day and cannot find anyone describing what I am seeing here. Can anyone offer some advice or assistance on how I can fix this?
    Thanks

    Following up.
    After messing around with the computer for a couple hours last night I discovered that the issue extended to iTunes having difficulty recognizing any iPod as well when I tried plugging in 3rd and 4th generation Nanos and a 3rd generation Touch that I had laying around.
    This morning I discovered, by viewing the 'About iTunes' option, that iTunes was under the impression that it was still version 11.1.3(8). When I ran a Software Update the computer said everything was up to date however, which would imply that somehow the computer was communicating that iTunes was version 11.1.4
    Working under the assumption that perhaps the issues I was seeing were the result of a botched installation of the update I downloaded the update of the web and then ran the update from the .dmg
    This solved the problem and now iTunes recognizes iPods and iPhone in a proper manner and all conflicting labeling has been restored to normal. I have no clue what caused the botched install but at least it is fixed

  • I have just purchased a new macbook and need to sync my iphone with itunes, i understand that you can only sync your phone with one itunes account. I do not want to wipe my iphone when syncing with this new itunes account. Any advice welcome

    I have just purchased a new macbook and need to sync my iphone with itunes, i understand that you can only sync your phone with one itunes account. I do not want to wipe my iphone when syncing with this new itunes account. Any advice welcome

    1) authorize iTunes on the new machine for your iTunes store account(s)
    2) connect your device and right-click or control-click it in the iTunes Source list, then choose transfer purchases from the shortcut menu that appears.
    3) sync the device
    iTunes will wipe the iPhone but, since you transferred your purchases in the previous step, your content will be in your library and you can re-populate the iPhone with it.

Maybe you are looking for

  • [JHS 10.1.3] Pages in WEB-INF

    Hi, I am generating a project using JHeadstart 10.1.3 with the default setting for the UI Pages directory (/WEB-INF/page) When I try to deploy to OC4J standalone, the pages in the WEB-INF directory are not accessible. I read that I have to construct

  • HT4437 My airplay button is gone...NOTHING works to get it back

    Is there any REAL WAY  to steam from my ipad to Apple TV with the upgrades hoe.  I lost my airplay icon and gave up on finding it til today....any more suggestions Thanks....judy

  • How i will configure handling unit(3shirt in one pocket and 10 pocket in ca

    Hi MM guru,,, i want to know how Handling unit  is configured.. actually my client is garment company... senero is shirt pack in one pocket..and 10 pocket pack in one cartoon... then how i will configure this and in sales order what will be material

  • Problem:  Unable to call a function in parent swf from the child swf.

    I am working on a site right now that has a parent loader (all it contains are the menu bar [which is as3 tweened] and the functions for calling all of the other pages.) The problem that I am having right now, are some of the internal or child pages,

  • Clear signature using Javascript

    Hi, i would like to know , How can i clear the signature by using java script in adobe X11 i have button , once i click on the button particular signature must be cleared. Any suggestion will help.