Sync 1 socket between 2 threads.

consider this code:
Socket sok = new Socket('192.158.9.42", 5432);
ThreadClass_1 t1 = new ThreadClass_1(sok);
t1.start();
ThreadClass_2 t2 = new ThreadClass_2(sok);
t2.start();
t1 needs to download a large file. then t2 takes over
for the remaining work. so... things are not going well.
what is the best way to make sure t2 doesn't
start using the Socket before t1 is finished
with it?
should this approach be working? i think it looks like a hack?
i really don't know.
private Object lock = new Object();
Socket sok = new Socket('192.158.9.42", 5432);
synchronized(lock) {
  ThreadClass_1 t1 = new ThreadClass_1(sok, lock);
  t1.start();
synchronized(lock) {
  lock.wait();
  ThreadClass_2 t2 = new ThreadClass_2(sok);
  t2.start();
       private class ThreadClass_1 extends Thread {
           private Object lock;
           private Socket sok;
           ThreadClass_1(Socket sok, Object lock) {
               this.sok = sok;
               this.lock = lock;
             public void run() {
                   // do my business with sok
                 this.lock.notify();
should that work?
is there anyway to do this without passing the lock down to
ThreadClass_1 in the constructor?
and, i'd rather not use some static boolean.
thanks.

i got it.
this is what i need:
Socket sok = new Socket('192.158.9.42", 5432);
ThreadClass_1 t1 = new ThreadClass_1(sok);
t1.start();
t1.join()  // <----
ThreadClass_2 t2 = new ThreadClass_2(sok);
t2.start();and then seriously decrease the size of the write buffer.

Similar Messages

  • Hi all, i can't sync over wifi between my iPhone 4 and Windows 7 64 bit, wifi sync works with the same phone and my Windows 8 machine, tried solutions from other threads with no luck, just thought i'd see if anyone else had any ideas, thanks.

    Hi all, i can't sync over wifi between my iPhone 4 and Windows 7 64 bit, wifi sync works with the same phone and my Windows 8 machine so the problem seems confined to Windows 7. I've tried solutions from other threads -
    Making sure everything is allowed through firewall
    Rebooting phone/laptop/router
    Disabling ipv6
    Disabling all networks except the one curently on
    Re-installing iTunes
    Restoring iPhone
    No luck with any of those unfortunately so i just thought i'd see if anyone else is still without wifi sync after trying those as well and if you ever found a fix, thanks.

    I just wanted to leave a note that it's working now. I'm not sure if it was the latest iTunes update that got it working or that i decided to start a new library instead of using the one i had backed up on Windows 8 (it didn't occur to me to check using the old library when i re-installed iTunes). But if anyone is having this problem, it might be worth trying again with a new installation of iTunes to see if the latest update works for you, and if not, try using a fresh library instead of a backup (by fresh library i mean discard your old library completely and start a new library, not just restore as new iPhone, a whole new library).

  • Sync my files between my pc phone and tablet

    how can i use my 2gb free creativ cloud to sync my files between my pc phone and tablet

    Mylenium,
    It works fine between my iPhone 4s PS touch and my Samsung galaxy note 10.1 with PS touch But not with my computer Windows 8 Adobe Photoshop  elements 11
    I dont see the cloud files on my computer
    Verstuurd vanaf mijn iPhone
    Op 18 aug. 2013 om 08:58 heeft Mylenium <[email protected]> het volgende geschreven:
    Re: sync my files between my pc phone and tablet
    created by Mylenium in Adobe Creative Cloud - View the full discussion
    What phone? What tablet? What files? You will have to explain better.
    Mylenium
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5604082#5604082
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5604082#5604082
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5604082#5604082. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Adobe Creative Cloud by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Syncing Mail Notifications Between Mac and iPhone

    Hi
    I been having this problem with the mail notifications not syncing between the Mail.app on my MacBook Pro and iPhone. Let me explain:
    When I get a new email, I hear the sound and see the red notification icon appear on both the MacBook and the iphone. When it comes to checking the new email, here are the two possible scenarios:
    a) If I check the new email on my phone, the red notification icon disappears from BOTH the iphone and the MacBook.
    b) If I check the new email on my MacBook, the red notification disappears from the MacBook but DOESN'T disappears from the iPhone (that is until I open the app). This happens with both cases, when the app is "running" in the background or when it is complety closed.
    I don't know if I am crazy but I am pretty sure that both of the notifications used to disappear before, no matter where I checked the mail.
    I tried deleting and creating the email again on my phone, and it didn't work.
    Here some info that could help find a solution:
    - I'm using icloud email (@me.com)
    MacBook
    -Mountain Lion
    iPhone:
    - iOS 6 (this problem started before the upgrade)
    - Push is on.
    - Fetch (that suppodselly would be used only if push is off) is set to Manually.
    - On the "Advanced" sub-menu inside the Mail settings, Push is also selected.
    Hopefully this can actually be fix and I can prove myself that I was not crazy!!
    Thanks in advance for the help!!

    Anyone find a fix for this problem? I've been waiting for this since notification syncing was announced a couple years ago with iOS 6. I use iCloud for my email and find it very frustrating that when I read an email on my Mac or on iCoud.com that it doesn't automatically dismiss the notifications for those emails on my iOS devices until I open the mail app on each iOS device. Notification syncing works great with other apps. With iMessages, for example, when I read a message on my Mac running Yosemite, the notifications disappear on my iOS devices without opening the messages app (badge app icon, home screen notifications and notification center). Why can't they figure this out with email? I remember at my old job, I had an exchange account that properly synced mail notifications between devices, but it has never worked with my iCloud email. I wonder if I am just missing a particular setting or if Apple just blew it here. Any info would be greatly appreciated.

  • Syncing iTunes Library between multiple user accounts

    Is it possible for iTunes to automatically sync music libraries between two user accounts on Windows XP?

    If I understand your question correctly , you can have identical libraries (contents, playlists and all) if you set each user's account to reference the same .itl file.
    Have a look at this article in the Apple Knowledge Base for details on how to do so.
    By using the Choose Library option and linking the accounts to the same .itl file, the libraries will be the same and changes made to one will be reflected in the others.
    Post back if you need any further details.

  • How do I sync my email between my iPhone and iPad?

    How do I sync my email between my iPhone and iPad?

    A razmee209 said, set up your email in settings on both devices. 
    iPhone email will always be up to date.  
    The iPad will update when it has internet connection.   If it is a wifi only iPad, it will only update when connected to wifi, but will do so automatically.

  • How do I sync game progress between iphone and ipad

    I have several  "long term progress" games on my iphone 5.I bought an ipad mini and would like to sync the progress of each game on both devises.I have have game game progress erased in the past, possible from incorrect procedure.
    What is the best was to sync devises. I was told at the Apple store to sign in each game with Facebook and the progress would then be the same on either devise. Any proven methods that work ?

    Hey Lkr100,
    Thanks for the question, and welcome to Apple Support Communities.
    It sounds like you want to sync calendar events between your iPhone and iPad (3rd gen). I would recommend using iCloud, which you can read about here:
    Apple - iCloud - Your content. On all your devices.
    http://www.apple.com/icloud/
    Thanks,
    Matt M.

  • Sync a folder between two users on the same computer.

    I would like to sync a folder between two users on the same computer so that they are always the same when I access them from either user.

    then place this folder somewhere where both users have access to like in /Users/Shared. then there is only one folder to deal with and you don't need to sync anything.

  • How do I sync my calendar between iPhone and Mac on Mavericks? The postings I've seen so far are not showing me how to do this simple thing! Apple used to be easy to use - not so much any more

    I am trying to sync my calendar between the mac and my iphone now that I have upgraded to Mavericks. I understand that I have to use iCloud (which I am not at all excited about) but I'll be damned if I can find out how to do it.  I've read several postings in the community but they point me to broad troubleshooting pages and I can't find anything that simply tells me how to get my calendar into icloud to begin with and then how to sync.  i was pretty happy syncing dircetly through itunes.  I am feeling very sour about Apple right now.

    Actually it is pretty easy to do through iCloud,
    On your Mac(s)
    System Preferences > iCloud
    Be sure the services you want to sync through iCloud are checked
    click on Account Details and be sure your Apple ID is correct
    On your iPhone
    Settings > iCloud
    Account -- Verify the Apple ID is the same one you set in System Preferences on your Mac(s)
    turn the services you want to sync throug iClound or ON. These should match the ones you set in System Preferences on your Mac
    On your iPad
    Settings > iCloud
    Account -- Verify the Apple ID is the same one you set in System Preferences on your Mac(s)
    turn the services you want to sync throug iClound or ON. These should match the ones you set in System Preferences on your Mac
    That is literally all there is to it. The first sync will occur when your iPhone or iPad is plugged into power and on WiFi. After that any change made on one of the synched devices will appear on all of the other synched devices the first time they have an internet connection.

  • How do I sync Pages docs between my Macbook and a PC?

    I want to sync Pages documents between my Macbook and a PC, for when I don't have the Macbook with me. I created a Pages file and saved it to iCloud, but it doesn't appear in the iCloud Pages web interface, even though other docs created in the web interface do.
    Sorry to ask such a basic question, but I can't figure this out. If I'm working in Pages on my Mac and save the document, it's like it goes someplace different than when I create a Pages doc on the web interface...
    Seriously confused, and not understanding how this works. Apologies for being such a beginner. This is really the only thing I want to use iCloud for.

    Thanks, Rick. I have identified another part of the answer -- my husband and I both use this MacBook. We have separate IDs and iCloud accounts. But apparently only one account is allowed to store iWork files on iCloud. Apparently when his iPhone was set up, or maybe when he borrowed the MacBook for a business trip, or when he took some pictures with his new iPhone -- who knows how or when -- the storage capability got attached to his iCloud account on my computer. I started to sign him out, then was told that if that was done, the photostream would be deleted.
    At this point the complexity is beyond ridiculous. We have 3 Mac devices, two computers and a phone, and I can't figure out the logic behind this limitation. I wish I had spent the hours that were invested in this effort in something more productive. I don't think iCloud is ready for primetime yet.

  • ICloud keeps syncing my Notes between my iPad/iPhone

    iCloud keeps syncing my Notes between my iPad and iPhone, even though Notes is turned off in iCloud on both devices. How can I prevent this from happening?

    Thanks a lot, fromsouth, your advice solved my problem!
    I turned off notes from mail contacts and calendars on my iPad, this cleared all the notes on that device.
    If I turn it back on again, all the notes present on the iPhone appear on the iPad.
    This is exactly what I wanted.
    Just FYI, I have only the one email account on both iOS devices as well as my PC.
    I rarely back up to the PC and the last time I did that was about 3 months ago and at different dates for each device. Yet the sync was happening every time I added a note to either device, before or after those backups.
    So, I'm still a little confused about which does the sync - iCloud or PC?

  • Sync maps bookmark between iPad and iPhone

    Hello
    I would like to sync maps bookmark between my iPad 2 and iPhone 4
    Is there a way to do that ?

    There is actually a way via contacts, but not a convenient one.
    You have to do it one by one for your existing bookmarks in Maps.
    You need a Mac to seperate those "bookmark contacts" from your regular contacts.
    I use this method now instead of the Maps bookmarks.
    0. Make the necessary setting to sync your contacts with iCloud on your iOS devices (and your Mac if you want to use a "bookmark group")
    1. Open a bookmark in Maps (or search for something) then click on the i-icon
    2. Choose to put it in a new Contact (modify info as you  like)
    3. Add item for Notes with the text "bookmark"
    This "bookmark contact" will now be synced through iCloud to your Mac and other iOS devices
    I don't want my contacts to be cluttered with those "bookmark contacts", so I choose to create a seperate group
    4. In addressbook on the Mac do a search for "bookmark"
    5. select file --> New group from selection
    6. after you've added additional "bookmark contacts" in Maps on your iPhone or iPad you have to search and select them and then drag them to your "bookmark group" in address book on the Mac

  • How NOT to sync game saves between devices?

    Hi there,
    I haven't been able to find out how NOT to automatically sync game saves between devices. I own both an iPhone 4 and an iPhone 5 and I do not want my progress in video games to be synchronized between the devices. There are no in-app settings in any of the games I own regarding this.
    Help please
    Rudy

    Game settings are part of the backup. You'll have to restore your iPad from the latest backup of the iPhone if you want the same game settings on it. But all other settings and data will be transferred as well from the phone, you can't just restore parts of the backup.
    Have a look a this article:
    iTunes: About iOS backups

  • Cloud Newbie: What is the best way to sync content files between locations?

    Not new to Dreamweaver, but am new to the Creative Cloud.  I typically carry an external drive with my web files and update site from home or work computer using those files.  Now that I'm using Dreamweaver CC, I'm trying to find the most efficient way to sync content files between computers.  I see that the "Sync Settings" allows for syncing of preferences - but not content. Anyone have a recommendation? Or do I simply make my changes at work. Then go home and download the page I made changes to update my home files?
    Thanks,
    George

    The Cloud isn't going to synch your site files between 2 computers.  That's not what it's for.
    You might want to explore file check-in/out feature in DW. 
    http://help.adobe.com/en_US/dreamweaver/cs/using/WSc78c5058ca073340dcda9110b1f693f21-7ebfa .html
    This lets you check files in/out from your Remote server.  That way, you know you're working on the lastest copy. Check-in/out is typically used in collaborative environments where 2 or more people work on the site.  But it might serve your needs as well.
    Nancy O.

  • Is there a way to Move files to the iCloud thus freeing up disk space on my Mac? Or does iCloud only sync (replicate) files between my Mac and the cloud?

    Is there a way to Move files to the iCloud thus freeing up disk space on my Mac? Or does iCloud only sync (replicate) files between my Mac and the cloud? I want to free up disk space on my Mac and assumed that the icloud would be a good way to do this, but having 'moved' 70Gb of files to the iCloud drive (I've upgraded to 200Gb storage) my Mac is still nearly full and I've realised that it seems to just Sync files just like dropbox.

    So, the big question is did the Apple guys confirm that this is how the new iCloud drive should be working?  I'm guessing, from your response, that this is indeed the case.  Are they going to fix this anytime soon?  I thought that this was a new function of the iCloud drive in Yosemite.
    I just want an online storage facility to back up my photo & music collections.  I did look at Dropbox as they have a good deal going with their Dropbox Pro, however this is still just a sync service where the Master files reside on your local disk drive - although I have read that there may be a way to work around this.  Still not ideal.

Maybe you are looking for

  • How to put user comments in WSDL File through webservices

    I created one web service application and i deployed and it is running. Now I want to put comments (like what is the parameters, type) in wsdl file for each method in my web service. I am using web logic server 8.1 service pack 2. Any can give answer

  • Days Since Jan 1, 1900.  Days of the week

    If I Had a long date, 04/16/2002 would be something like 37362. How can I figure out what day of the week it would be?

  • Problem with array type in SOAP response for sync interface

    Hi, We have a Synchronous Interface from SAP -->PI-->Unifier .The WSDL response has array type and when WSDL is imported it is showing red (I was able to activate  and use it in mapping) .We are able to send the request successfully and when retrievi

  • PC Suite "Data Transfer Not Possible" 6500 Classic

    Can transfer music files and send and receive SMSs in the PC suite, but contacts and calendar wont sync. Have correct firmware. Using data cable. Have general profile activated. Have tried with and without Sim card. Any other ideas before I finally g

  • Material configuration with BAPI_SALESORDER_CREATEFROMDAT2

    Hi there, I am trying to create a new sales order with material configuration using BAPI_SALESORDER_CREATEFROMDAT2. It's not working though. I have seen some comments that it is not possible to create configuration directly with this BAPI - is this r