java吧 关注:1,258,196贴子:12,750,756

为尽快提高本吧人气,欢迎大家建言献策——重新振兴本吧

只看楼主收藏回复



1楼2009-10-24 11:37回复
    昨晚上发的帖子现在0回复,谈什么复兴
    http://tieba.baidu.com/f?kz=660905529


    6楼2009-10-28 07:53
    回复
      我觉得吧里应该定期搞一些活动,比如编程大赛呀。会员见面呀。贴吧之星之类的,这样能提高大家的热情的积级性。


      7楼2009-10-28 10:15
      回复
        牛逼点的资源分享  牛逼点的技术文章  再来点活动


        8楼2009-10-28 17:05
        回复
          • 60.176.38.*
          广告铺天盖地,吧主无能,去海吧学习去


          9楼2009-10-29 08:43
          回复
            • 218.108.43.*
            建立个交流平台,分享资源~定期做些活动等等……


            10楼2009-10-29 09:27
            回复
              ok,大家的建议挺好的,我会尽快着手办。


              11楼2009-10-29 15:43
              回复
                把会员要求降低吧 20条帖子那个


                13楼2009-10-31 18:35
                回复
                  泡吧喝酒


                  14楼2009-11-01 00:08
                  回复
                    .................


                    IP属地:北京15楼2009-11-01 10:48
                    回复
                      • 58.54.152.*
                      java,.net,sql,交流群94429054,欢迎加入


                      17楼2009-11-04 22:13
                      回复
                        哲学家吃饭的问题,死循环
                        import java.util.Random;
                        public class DiningPhils
                        {
                        public static void main(String[] args)
                        {
                            int n = 10;
                            if( n < 1)
                            {
                             System.out.println( "DiningPils <# of philosophers>" );
                             System.exit(-1);
                            }
                            DiningPhils self = new DiningPhils();
                            self.init(n);
                        }
                        public int getCount()
                        {
                            return n;
                        }
                        public void setChopstick( int i, boolean v)
                        {
                            chops[ i ] = v;
                        }
                        public boolean getChopstick( int i )
                        {
                            return chops[i];
                        }
                        private void init( final int N)
                        {
                            r = new Random();
                            n = ( N < 0 || N > maxPhils ) ? maxPhils : N;
                            chops = new boolean[n];
                            phils = new Philosopher[n];
                            initPhils();
                            dumpStatus();
                        }
                        private void initPhils()
                        {
                            for( int i = 0; i< n; i++ )
                            {
                             phils[i] = new Philosopher( this, i );
                             phils[i].setTimeSlice( generateTimeSlice());
                             phils[i].setPriority( Thread.NORM_PRIORITY - 1);
                        /**哲学家进程降低一级,使所有哲学家进程
                        *全部初始化完毕前不会有哲学家进程抢占主线程*/
                            }
                            while( moreToStart() )
                            {
                             int i = Math.abs( r.nextInt()) % n;
                             if( !phils[i].isAlive())
                             {
                              System.out.println( " ### Philosopher " +
                                String.valueOf( i ) + " started.");
                              phils[i].start();
                             }
                            }
                            System.out.println( "\nPhilosophers                Chopsticks"
                              + "\n(1 = eating, 0 = thinking)    (1 = taken, 0 = free)");
                        }
                        public int generateTimeSlice()
                        {
                            int ts = Math.abs(r.nextInt()) %    (maxEat + 1);
                            if( ts == 0 )
                             ts = minEat;
                            return ts;
                        }
                        public void dumpStatus()
                        {
                            for( int i = 0; i < n; i++)
                             System.out.print(phils[i].getEat() ? 1 : 0);
                            for( int i = n; i < maxPhils + 4; i++ )
                             System.out.print(" ");
                            for( int i = 0; i < n; i++)
                             System.out.print(chops[i]? 1:0);
                            System.out.println();
                        }
                        private boolean moreToStart()
                        {
                            for( int i = 0; i < phils.length; i++ )
                            {
                        


                        IP属地:北京18楼2009-11-06 23:18
                        回复
                               if( !phils[i].isAlive())
                                return true;
                              }
                              return false;
                          }
                          private int n;
                          private Philosopher[] phils;
                          private boolean[] chops;
                          private Random r;
                          private static final int maxPhils = 24;    //最多哲学家数
                          2009-11-6 23:17 回复  
                          电脑千千问
                          143楼
                          private static final int maxEat = 4;     //最多进餐时间
                          private static final int minEat = 1;     //最少进餐时间
                          }
                          class Philosopher extends Thread
                          {
                          public Philosopher( DiningPhils HOST , int i )
                          {
                              host = HOST;
                              index = i;
                          }
                          public void setTimeSlice( int TS )
                          {
                              ts = TS;
                          }
                          public void setLeftChopstick( boolean flag )
                          {
                              host.setChopstick(index, flag);
                          }
                          public void setRightChopstick( boolean flag )
                          {
                              host.setChopstick((index + 1)% host.getCount() , flag);
                          }
                          private void releaseChopsticks()
                          {
                              setLeftChopstick(false);
                              setRightChopstick(false);
                          }
                          public boolean chopsticksFree()
                          {
                              return !host.getChopstick(index) &&
                              !host.getChopstick((index+1)%host.getCount());
                          }
                          public void run()
                          {
                              while(true)
                              {
                               grabChopsticks();
                               eat();
                               think();
                              }
                          }
                          private synchronized void grabChopsticks() /**临界区函数,确保哲学家在没有筷子或筷子不够时思考,满足条件后才就餐*/
                          {
                              while( !chopsticksFree())
                              {
                               try
                               {
                                wait();
                               }
                               catch( InterruptedException e){}
                              }
                              takeChopsticks();
                              notifyAll();
                          }
                          private void takeChopsticks()
                          {
                              setLeftChopstick( true );
                              setRightChopstick( true );
                              setEat(true);
                              host.dumpStatus();
                          }
                          private void eat()
                          {
                              pause();
                              setEat( false );
                              releaseChopsticks();
                          }
                          private void think()
                          {
                              pause();
                          }
                          private void pause()
                          {
                              setTimeSlice( host.generateTimeSlice());
                              try
                              {
                               sleep(ts*1000);
                              }
                              catch( InterruptedException e){}
                          }
                          private void setEat(boolean v)
                          {
                              isEating = v;
                          }
                          public boolean getEat()
                          {
                              return isEating;
                          }
                          private DiningPhils host;
                          private boolean isEating;
                          private int index;
                          private int ts;
                          }
                          


                          IP属地:北京19楼2009-11-06 23:18
                          回复
                            • 59.55.127.*
                            看看C++吧的置顶帖``
                            我们都学


                            20楼2009-11-07 23:46
                            回复
                              帮我写个程序嘛! 编写程序完成简单计算器的功能:加、减、
                              Number1、Number2、Result 是三个JLabel 控件,它们后面的是三个 JTextField控件,用来输入操作数并显示运算结果;窗体下边是四个JButton控件Add、Subtract、Multiply、Divide,分别代表加、减、乘、除运算,点击是进行相应的运算并显示结果;窗体上边的菜单完成同样的功能。<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 乘、除


                              21楼2009-11-08 10:31
                              回复